akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define swap(a,b) a^=b^=a^=b //二変数を入れ替え//
#define inf 1000000007
int main(void) {
	// your code goes here
	int h,w,i,j;
	char s[52][52];
	scanf("%d %d",&h,&w);
	scanf("%c",&s[0][0]);
	for(i=1;i<=h;i++){
		for(j=1;j<=w+1;j++){
			scanf("%c",&s[i][j]);
		}
	}
	for(i=0;i<=h+1;i++){
		s[i][0]='.';
		s[i][w+1]='.';
	}
	for(j=0;j<=w+1;j++){
		s[0][j]='.';
		s[h+1][j]='.';
		
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(s[i][j]=='#'&&s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);

  cout << ans << endl;
}

int main() {
  sws;
  solve();
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n, t, x, y, a, b, c;
  	cin >> n;
    t = x = y = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        int dist = abs(x-b) + abs(y-c);
        if (dist > a-t || dist%2 != (a-t)%2) {
            puts("No");
            return 0;
        }
        t = a, x = b, y = c;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int X;
    cin >> X;
    ll cnt =  1;
    ll rad = X;
    while(rad != 0) {
        cnt ++;
        rad += X;
        rad%=360;
    }

    cout << cnt<< endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    stack<int> st;
    int ans = 0;
    int lim = S.size();
    st.push('z');
    rep(i,lim){
        char t = S[i];
        if(t != st.top() && st.top() != 'z'){
            ans++;
            st.pop();
        }
        else{
            st.push(t);
        }
    }
    cout << ans * 2 << endl;
}

Measured memory_bytes: 768
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define erep(i,n) for (int i = 1; i <= (n); ++i)
#define brep(i,n) for (int i = n; i >= 0; i--)
#define PI 3.14159265359
using namespace std;
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<int> > ;
const int INF = 100005;
const int MAX_K = 55;
const int MAX_W = 200005; 
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// ユークリッド互除法
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}
*/

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  int k;
  ll ans = 0;
  cin >> k;
  erep(i,k){
    erep(j,k){
      erep(l,k){
        ans += gcd(gcd(i,j),gcd(j,l));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
int main() {
    int a[4], k; std::cin >> a[0] >> a[1] >> a[2] >> k;
    int n = 0;
    for (int i = 1 ; i < 3; i++){
        if (a[n] < a[i]) {
            n = i;
        }
    }

    for (int i = 0; i < k; i++) {
        a[n] *= 2;
    }

    std::cout << (a[0] + a[1] + a[2]) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
const int N = 1e5 + 50;
int n, m, k, u, v, fu, fv;
int f[N], vis[N], cnt[N], d[N];
vector<int>e[N];

int Find(int x) {
    return (x == f[x]) ? f[x] : f[x] = Find(f[x]);
}

int main() {
    for(int i=0;i<N-20;i++)f[i] = i, d[i] = 0;

    cin>>n>>m>>k;
    for(int i=0;i<m;i++) {
        scanf("%d%d", &u, &v);
        cnt[u] ++;
        cnt[v] ++;
        fu = Find(u);
        fv = Find(v);
        f[fu] = fv;
    }

    for(int i=1;i<=n;i++) {
        fu = Find(i);
        d[fu] ++;
    }

    for(int i=0;i<k;i++) {
        scanf("%d%d", &u, &v);
        if(f[u] == f[v]) {
            cnt[u] ++;
            cnt[v] ++;
        }
    }

    for(int i=1;i<=n;i++) {
        printf("%d%c",d[f[i]]-cnt[i]-1, (i==n)?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] arr = new int[n];
        final int L = 60;

        int[][] to = new int[L][n];

        for (int i=0; i<n; i++) {
            to[0][i] = sc.nextInt() - 1;
        }

        for (int i=1; i<L; i++) {
            for (int j=0; j<n; j++) {
                to[i][j] = to[i-1][to[i-1][j]];
            }
        }

        int v = 0;
        for (int i=L-1; 0<=i; i--) {
            long l = 1L << i;
            if (l <= k) {
                v = to[i][v];
                k -= l;
            }
        }

        System.out.println(v + 1);

    }

}


Measured memory_bytes: 121952
#include<stdio.h>
#define min(x,y) ((x) < (y) ? (x) : (y))


int main(){
  int n, k, i;
  scanf("%d %d", &n, &k);
  for(i = 0;i < k;i++){
    int x, y;
    scanf("%d%d", &x, &y);
    x = min(x, n + 1 - x);
    y = min(y, n + 1 - y);
    printf("%d\n", (min(x, y) - 1) % 3 + 1);    
  }
  return 0;
}

Measured memory_bytes: 596
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int p[][12],int q[][12],int x){
  int i,j;
  int r[12][12],s[12][12];
  if(x==11){
    for(i=2;i<10;i++){
      for(j=1;j<11;j++){
	if(p[j][i]){
	  p[j  ][i  ]=(p[j  ][i  ]+1)%2;
	  p[j-1][i+1]=(p[j-1][i+1]+1)%2;
	  p[j  ][i+1]=(p[j  ][i+1]+1)%2;
	  p[j+1][i+1]=(p[j+1][i+1]+1)%2;
	  p[j  ][i+2]=(p[j  ][i+2]+1)%2;
	  q[j][i+1]=1;
	}
      }
    }
    for(i=1;i<11;i++){
      if(p[i][10])
	break;
    }
    if(i==11){
      for(i=1;i<11;i++){
	for(j=1;j<10;j++)
	  cout<<q[j][i]<<" ";
	cout<<q[j][i]<<endl;
      }
      return 1;
    }
  }else if(x==10){
    if(p[x][1]){
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      r[x  ][1]=(r[x  ][1]+1)%2;
      r[x-1][2]=(r[x-1][2]+1)%2;
      r[x  ][2]=(r[x  ][2]+1)%2;
      r[x+1][2]=(r[x+1][2]+1)%2;
      r[x  ][3]=(r[x  ][3]+1)%2;
      s[x  ][2]=1;
      if(f(r,s,x+1))
	return 1;
    }else{
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      if(f(r,s,x+1))
	return 1;
    }
  }else{
      if(p[x][1]){
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      r[x+1][0]=(r[x+1][0]+1)%2;
      r[x  ][1]=(r[x  ][1]+1)%2;
      r[x+1][1]=(r[x+1][1]+1)%2;
      r[x+2][1]=(r[x+2][1]+1)%2;
      r[x+1][2]=(r[x+1][2]+1)%2;
      s[x+1][1]=1;
      if(f(r,s,x+1))
	return 1;
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      r[x  ][1]=(r[x  ][1]+1)%2;
      r[x-1][2]=(r[x-1][2]+1)%2;
      r[x  ][2]=(r[x  ][2]+1)%2;
      r[x+1][2]=(r[x+1][2]+1)%2;
      r[x  ][3]=(r[x  ][3]+1)%2;
      s[x  ][2]=1;
      if(f(r,s,x+1))
	return 1;
    }else{
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      if(f(r,s,x+1))
	return 1;
      memcpy(r,p,sizeof(r));
      memcpy(s,q,sizeof(s));
      r[x+1][0]=(r[x+1][0]+1)%2;
      r[x  ][1]=(r[x  ][1]+1)%2;
      r[x+1][1]=(r[x+1][1]+1)%2;
      r[x+2][1]=(r[x+2][1]+1)%2;
      r[x+1][2]=(r[x+1][2]+1)%2;
      s[x+1][1]=1;
      r[x  ][1]=(r[x  ][1]+1)%2;
      r[x-1][2]=(r[x-1][2]+1)%2;
      r[x  ][2]=(r[x  ][2]+1)%2;
      r[x+1][2]=(r[x+1][2]+1)%2;
      r[x  ][3]=(r[x  ][3]+1)%2;
      s[x  ][2]=1;
      if(f(r,s,x+1))
	return 1;
    }
  }
  return 0;
}
int main(){
  int i,j,k;
  int q[12][12],r[12][12],n;
  int (*p)[12][12];
  cin>>n;
  p=new int[n][12][12];
  for(i=0;i<n;i++)
    for(j=1;j<11;j++)
      for(k=1;k<11;k++)
	cin>>p[i][k][j];
  for(i=0;i<n;i++){
    memcpy(r,&p[i][0][0],sizeof(r));
    memset(q,0,sizeof(q));
    f(r,q,1);
    memcpy(r,&p[i][0][0],sizeof(r));
    memset(q,0,sizeof(q));
    r[1][0]=(r[1][0]+1)%2;
    r[0][1]=(r[0][1]+1)%2;
    r[1][1]=(r[1][1]+1)%2;
    r[2][1]=(r[2][1]+1)%2;
    r[1][2]=(r[1][2]+1)%2;
    q[1][1]=1;
    f(r,q,1);
  }
  delete [] p;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;



// 1 100




int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k;
	cin>>k>>n;
	if(n==100){
		cout<<101;
	}
	else{cout<<n;}
	FOR(i,0,k){
		cout<<"00";
	}
	return 0;
}


Measured memory_bytes: 256
num = []
for i in range(3):
  num.append(list(map(int,input().split())))
  
ans = []
  
for i in range(3):
  temp = []
  for j in range(3):
    temp.append(num[j][i])
  ans.append(temp)
  ans.append(num[i])

for i in range(1):
  temp = []
  for j in range(3):
    temp.append(num[j][j])
  ans.append(temp)
  
for i in range(1):
  temp = []
  temp.append(num[0][2])
  temp.append(num[1][1])
  temp.append(num[2][0])
  ans.append(temp)
N = int(input())
for i in range(N):
  X = int(input())
  for j in range(8):
    if X in ans[j]:
      ans[j].remove(X)

f = True
for i in range(8):
  if len(ans[i]) == 0:
    print('Yes')
    f = False
    break
if f:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int main(){
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n, 0);
    vector<ll> ans(n, k);
    rep(i, q){
        ll aa;
        cin >> aa;
        aa--;
        a[aa]++;
    }
    rep(i, n){
        if(ans[i] - (q - a[i]) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 2176
h,n=map(int,input().split())

a=[]
b=[]
INF=10**9
dp=[INF for i in range(h+10**4)]

for i in range(n):
  p,q=map(int,input().split())
  a.append(p)
  b.append(q)

dp[0]=0
for i in range(h):
  if dp[i]==INF:
    continue
  for j in range(n):
    if dp[i+a[j]]>=dp[i]+b[j]:
      dp[i+a[j]]=dp[i]+b[j]
print(min(dp[h:]))

Measured memory_bytes: 41836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	vi vec;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x; vec.pb(x);
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<k;i++) ans+=vec[i];
	cout<<ans<<'\n';
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
		int[] value = new int[n];
		int[][] skill = new int[n][m];
		for(int i = 0; i < n; i++) {
			value[i] = sc.nextInt();
			for(int j = 0; j < m; j++) {
				skill[i][j] = sc.nextInt();
			}
		}
 		int ans = Integer.MAX_VALUE;
 		int[][] list = makeList(n);
		for(int r = 0; r < (int)Math.pow(2, n); r++) {
			int[] buy = list[r];
			int[] totalS = new int[m];
			int money = 0;
			for(int i = 0; i < n; i++) {
				money += buy[i]*value[i];
				for(int j = 0; j < m; j++) {
					totalS[j] += buy[i]*skill[i][j];
				}
			}
			boolean check = true;
			for(int i = 0; i < m; i++) {
				if(totalS[i] < x) {
					check = false;
					break;
				}
			}
			if(check && ans > money) {
				ans = money;
			}
		}
		if(ans == Integer.MAX_VALUE)ans = -1;
		System.out.println(ans);
	}
	
	static int[][] makeList(int n) {
		int all = (int)Math.pow(2, n);
		int[][] list01 = new int[all][n];
		for(int i = 0; i < all; i++) {
			Arrays.fill(list01[i], 0);
			int x = 0;
			int num = i;
			while(num >= 2) {
				list01[i][x] = num%2;
				x++;
				num = num/2;
			}
			list01[i][x] = num;
			x++;
		}
		return list01;
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 35248
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include <cstdlib>
#include<unordered_set>
#include<cmath>
#include<list>
#include<functional>
#include<cmath>
#include <iostream>
#include <fstream>
using namespace std;

int main() {
	string s;
	cin >> s;
	bool flag = false;
	bool avail = false;
	for (char c : s) {
		if (c == 'C') {
			flag = true;
		}
		else if (c == 'F'&&flag) {
			avail = true;
			break;
		}
	}
	string res = (avail) ? "Yes" : "No";
	cout << res<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> X.at(i).at(j);
        }
    }

    int distance = 0;
    int count = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            for (int k = 0; k < D; k++)
            {
                distance += pow(X.at(i).at(k) - X.at(j).at(k), 2);
            }
            if(pow((int)(sqrt(distance)),2)==distance){
                count++;
            }
            distance = 0;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
}

Measured memory_bytes: 38632
fun main(args:Array<String>) {
	val sb=StringBuilder()
	val (h,w) = readLine()!!.split(" ").map{ it.toInt() }
	val a=(1..h).map{ readLine()!!.split(" ").map{ it.toInt() }.toIntArray() }.toTypedArray()
	
	var count=0
	for(i in 0..h-1){
		for(j in 0..w-2){
			if(a[i][j]%2==1){
				count++
				a[i][ j ]--
				a[i][j+1]++
				sb.append(i+1).append(' ').append(j+1).append(' ')
				sb.append(i+1).append(' ').append(j+2).append('\n')
			}
		}
		if(i!=h-1 && a[i][w-1]%2==1){
			count++
			a[ i ][w-1]--
			a[i+1][w-1]++
			sb.append(i+1).append(' ').append(w).append(' ')
			sb.append(i+2).append(' ').append(w).append('\n')
		}
	}
	println(count)
	println(sb)
	
}

Measured memory_bytes: 59020
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n,m=map(int,stdin.readline().rstrip().split())
l=[[] for _ in range(m)]
h=[]
heapq.heapify(h)
for i in range(n):
    a,b=map(int,stdin.readline().rstrip().split())
    if a>m:
        continue
    l[m-a].append(b)
ans=0
for i in range(m-1,-1,-1):
    for j in l[i]:
        heapq.heappush(h,-j)
    if len(h)!=0:
        ans+=-(heapq.heappop(h))
print(ans)

Measured memory_bytes: 60976
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n) {
    int s = 1;
    loop(i, 1, n + 1) s += i;
    cout << s << endl;
  }
}

Measured memory_bytes: 3068
#include<iostream>

using namespace std;

const int MaxI = 51;
int C[MaxI][MaxI];
int Dh[] = {-1,-1,-1,0,0,1,1,1};
int Dw[] = {-1,0,1,-1,1,-1,0,1};
int H, W;

void dfs(int i, int j);

int main() {

  while(cin>>W>>H && !(W==0 && H==0)) {
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
	cin>>C[i][j];
      }
    }

    int ans = 0;
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
	if(C[i][j] == 1) {
	  dfs(i,j);
	  ans++;
	}
      }
    }
    cout<<ans<<endl;
  }
}

void dfs(int i, int j) {
  C[i][j] = 0;
  for(int a=0; a<8; a++) {
    if(0<=i+Dh[a] && i+Dh[a]<H && 0<=j+Dw[a] && j+Dw[a]<W && C[i+Dh[a]][j+Dw[a]] == 1) {
      dfs(i+Dh[a], j+Dw[a]);
    }
  }
}

Measured memory_bytes: 1240
/*
 * atcoder/abc143_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * c =< a + b - 1
 * c >= abs(b - a) + 1
 */
int N;
vector<int> L;
void solve() {
  cin >> N;
  L.resize(N);
  loop(n,0,N) cin >> L[n];
  sort(L.begin(), L.end());

  ll total = 0;
  for (int i=N-1; i>=2; i--) {
    int a = L[i];
    for (int j=i-1; j>=1; j--) {
      int b = L[j];
      int count = upper_bound(L.begin(), L.begin()+j, a + b - 1) - lower_bound(L.begin(), L.begin()+j, a-b+1);
      // cout << a << " " << b << " " << count << endl;
      total += count;
    }
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    while(1){
    if(n == 111){cout << 111 << endl;return 0;}
    if(n == 222){cout << 222 << endl;return 0;}
    if(n == 333){cout << 333 << endl;return 0;}
    if(n == 444){cout << 444 << endl;return 0;}
    if(n == 555){cout << 555 << endl;return 0;}
    if(n == 666){cout << 666 << endl;return 0;}
    if(n == 777){cout << 777 << endl;return 0;}
    if(n == 888){cout << 888 << endl;return 0;}
    if(n == 999){cout << 999 << endl;return 0;}
        n++;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, m;
    cin >> n >> m;
    cout << abs(n-m) << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP()(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  lint x = 0, minus = -1;
  rep (i, n) {
    minus *= -1;
    x += minus * a[i];
  }
  vector<int> ans(n);
  ans[0] = x;
  rep (i, 1, n)   ans[i] = 2 * a[i - 1] - ans[i - 1];
  rep (i, n) cout << ans[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    cout << s / 3600;
    s = s % 3600;
    cout << ":";
    cout << s / 60;
    cout << ":";
    cout << s % 60 << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
using namespace std;

int main() {
    int a;
    cin >> a;
    int n[4];
    for (int i = 0; i < 4; i++) {
        n[3 - i] = a % 10;
        a /= 10;
    }
    bool flag = false;
    int ans = 0;
    for (int i = 0; i < (1 << 3); i++) {
        int sum = n[0];
        for (int j = 0; j < 3; j++) {
            if (i >> j & 1)
                sum += n[j + 1];
            else
                sum -= n[j + 1];
        }
        if (sum == 7) {
            ans = i;
            break;
        }
    }
    cout << n[0];
    for (int j = 0; j < 3; j++) {
        if (ans >> j & 1)
            cout << "+";
        else
            cout << "-";
        cout << n[j+1];
    }
    cout << "=7\n";

}
    


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main (void){
        int n;
        char c;
        scanf("%d",&n);
        for (int i = 0; i < n; i++) {
                c=getchar();
                if(c=='Y') {
                        printf("Four");
                        return 0;
                }
        }
        printf("Three");
        return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a, b; cin >> a >> b;
    b++;
    long long ans = 0;
    for (int i = 0; i < 60; i++) {
        long long t = (1LL << i);
        long long s = t * 2;
        long long cnt = 0;
        cnt += (b / s) * t + min(max((b % s) - t, 0LL), t);
        cnt -= (a / s) * t + min(max((a % s) - t, 0LL), t);
        if (cnt & 1) ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
c = []
for _ in range(3):
  ci  = list(map(int,input().split()))
  c.append(ci)
if all([c[0][0]-c[0][1]== c[1][0]-c[1][1],c[1][0]-c[1][1]==c[2][0]-c[2][1],c[0][1]-c[0][2]==c[1][1]-c[1][2],c[1][1]-c[1][2]==c[2][1]-c[2][2]]):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 100005
#define M 30
using namespace std;
int n,k,c,depth[N],parent[N][M];
vector<int> e[N];

void dfs(int x,int d){
  depth[x]=d;
  for(int i=0;i<(int)e[x].size();i++)
    dfs(e[x][i],d+1);
}

int lca(int u,int v){
  if(depth[u]<depth[v])swap(u,v);
  int K=depth[u]-depth[v];
  for(int i=0;i<M;i++)
    if(K>>i&1)u=parent[u][i];
  if(u==v)return u;
  for(int j=M-1;j>=0;j--){
    if(parent[u][j]==parent[v][j])continue;
    u=parent[u][j];
    v=parent[v][j];
  }
  return parent[u][0];
}

int main(){
  cin>>n;
  memset(parent,-1,sizeof(parent));
  for(int i=0;i<n;i++){
    scanf("%d",&k);
    for(int j=0;j<k;j++){
      scanf("%d",&c);
      e[i].push_back(c);
      parent[c][0]=i;
    }
  }
  for(int j=1;j<M;j++)
    for(int i=0;i<n;i++)
      if(parent[i][j-1]==-1)parent[i][j]=-1;
      else parent[i][j]=parent[parent[i][j-1]][j-1];
  dfs(0,0);
  int q,u,v;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>u>>v;
    printf("%d\n",lca(u,v));
  }
  return 0;
}

Measured memory_bytes: 23496
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Integer.parseInt(sc.next());
        Map<String, Integer> map = new HashMap<>();
        long ans = 0;
        
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            if(map.containsKey(s)) {
                continue;
            }else {
                map.put(s, 1);
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 76664
n = gets.to_i
a_arr = gets.split.map(&:to_i)
b_arr = gets.split.map(&:to_i)
c_arr = gets.split.map(&:to_i)

prev = nil
result = 0
a_arr.each do |a|
  result += b_arr[a-1]
  if prev == a - 1
    result += c_arr[prev-1]
  end
  prev = a
end

puts result


Measured memory_bytes: 1788
#include<stdio.h>

int main(void){

int count = 0;
int r = 0;
char s[15];
int k;
scanf("%s", s);

for(int i = 0;i < 15; i++){
  if(s[i] == 'o'){
    count += 1;
  }
}

for(k=0; s[k]!='\0'; ++k);

r = 15 - k;

if(count + r >= 8){
  printf("YES\n");
}
else{
  printf("NO\n");
}
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
const ll MAX = 1e5 + 1;

ll modfac[MAX];
ll modfacinv[MAX];
ll invsi[MAX];

ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {
    return power(n, mod-2, mod);
}

inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

ll nCr(ll n, ll k){
	ll resd = 1;
    ll res = 1;
    if ( k > n - k )
        k = n - k;
    for (ll i = 0; i < k; ++i){
        res = mul(res, (n - i));
        resd = (mul(resd, i + 1));
    }
    return divi(res, resd);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n, a, b;
	cin>>n>>a>>b;
	ll ans = power(2, n, mod) ;
	ans  = sub(ans, (nCr(n, a) + nCr(n, b) + 1));
	cout<<(ans+mod)%mod;
	return 0;
}


Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            int x = nint(sc);
            int y = nint(sc);

            int[] group = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2 ,1 , 2, 1};
            out.println(group[x] == group[y] ? "Yes" : "No");
        }
    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 21716
h, w = list(map(int, input().split()))
s = [[c for c in input()] for i in range(h)]
ans = [[0] * w for i in range(h)]

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        num = 0
        for d in range(8):
            ni = i + dy[d]
            nj = j + dx[d]
            if ni < 0 or h <= ni:
                continue
            if nj < 0 or w <= nj:
                continue
            if s[ni][nj] == '#':
                num += 1
        s[i][j] = num
for l in s:
    print(''.join([str(c) for c in l]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    int n,r;
    cin >> n >> r;
    if(n < 10)pf(r + 100 * (10 - n));
    else pf(r);
    return 0;
}


Measured memory_bytes: 256
package main
 
import (
  "fmt"
)
 
func main() {
  var A, B, C int
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&C)
  
  ans := "NO"
  if A % B == C {
    ans = "YES"
  }
  for i := 2; (A*i)%B != A%B; i++ {
    if (A * i) % B == C {
      ans = "YES"
      break
    }
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<char> cnt;
	rep(i,n){
		char c;
		cin>>c;
		cnt.insert(c);
	}
	if(cnt.size()==4) cout<<"Four"<<endl;
	else cout<<"Three"<<endl; 
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {
    BigInteger kaijo[] = new BigInteger[300001];
    BigInteger inv_kaijo[] = new BigInteger[300001];
    long mod = 998244353;
    BigInteger bmod = BigInteger.valueOf(mod);
    BigInteger btwo = BigInteger.valueOf(2);

    public void main(Scanner sc) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        kaijo[0] = BigInteger.ONE;
        inv_kaijo[0] = BigInteger.ONE;
        for (int i = 1; i <= n; i++) {
            kaijo[i] = kaijo[i - 1].multiply(BigInteger.valueOf(i)).mod(bmod);
            inv_kaijo[i] = kaijo[i].modInverse(bmod);
        }

        long red, blue;
        long ans = 0;
        for (red = 0; red <= n && a * red <= k; red++) {
            if ((k - a * red) % b == 0) {
                blue = (k - a * red) / b;
                if (blue > n) {
                    continue;
                }

                ans += calc(n, red, blue);
                ans %= mod;
            }
        }

        System.out.println(ans);
    }

    private long calc(long n, long r, long b) {
        BigInteger ans = kaijo[(int) n].modPow(btwo, bmod);
        ans = ans.multiply(inv_kaijo[(int) r]).mod(bmod);
        ans = ans.multiply(inv_kaijo[(int) (n - r)]).mod(bmod);
        ans = ans.multiply(inv_kaijo[(int) b]).mod(bmod);
        ans = ans.multiply(inv_kaijo[(int) (n - b)]).mod(bmod);
        return ans.longValue();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 226336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    bool ok = false;
    rep(i,n-m+1)rep(j,n-m+1){
        bool res = true;
        rep(x,m)rep(y,m){
            if(a[i+x][j+y] != b[x][y]){
                res = false;
                break;
            }
        }
        if(res){
            ok = true;
            break;
        }
    }
    cout << (ok?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[8];

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   int r=0;
   for(int i=0;i<n;i++){
      cin>>a[i];
      if(a[i]<3200)cnt[a[i]/400]=1;
      else r++;
   }
   int ans=0;
   for(int i=0;i<8;i++){
      ans+=cnt[i];
   }
   if(ans==0){
      cout<<1<<" "<<r<<endl;
      return 0;
   }
   cout<<ans<<" "<<ans+r<<endl;

}

Measured memory_bytes: 256
use std::str::FromStr;



fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let nk : Vec<usize> = get_vec();
    let n = nk[0];
    let k = nk[1];
    let md = 1000000007;

    let mut fact : Vec<i64> = vec!(0;n+2);
    fact[0] = 1;
    fact[1] = 1;
    let mut inv : Vec<i64> = vec!(0;n+2);
    inv[1] = 1;
    let mut inv_fact : Vec<i64> = vec!(0;n+2);
    inv_fact[0] = 1;
    inv_fact[1] = 1;

    for i in 2..n+2 {
        let x = i as i64;
        fact[i] = (fact[i-1] * x) % md;
        inv[i] = (((-inv[(md%x) as usize] * (md/x)) % md) + md) % md;
        inv_fact[i] = (inv_fact[i-1] * inv[i]) % md;
    }

    //println!("{:?}", fact);
    //println!("{:?}", inv);
    //println!("{:?}", inv_fact);
    fn mod_comb(n : i64, k : i64, md : i64, fact : &Vec<i64>, inv_fact : &Vec<i64>) -> i64 {
        //println!("{} {} {}", n, k, n-k);
        if n < k {
            return 0;
        }
        return (((fact[n as usize] * inv_fact[k as usize]) % md) * inv_fact[(n-k) as usize]) % md;
    }


    for i in 1..k+1 {
        println!("{}", (mod_comb((n-k+1) as i64,i as i64,md,&fact,&inv_fact) * mod_comb((k-1) as i64,(i-1) as i64,md,&fact,&inv_fact)) % md);
    }
}


Measured memory_bytes: 4476
def main():
    a, b, c, k = map(int, input().split())
    res = 0

    res += 1 * min(a, k)
    k -= a
    if k > 0:
        k -= b
    if k > 0:
        res += (-1 * min(c, k))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=1e5+10,mod=1e9+7;
int n,cnt,head[N],vis[N],a[N];
int tot,cir_tot,q[N],fa[N],dep[N],mk[N],len[N];
int sum[N],ans,f[N];
struct edge{int to,nxt;}e[N<<1];

void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}

void dfs(int u,int par){
	vis[u]=1; tot++;
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((i^1)!=par){
			v=e[i].to;
			if (!vis[v]) fa[v]=u,dep[v]=dep[u]+1,dfs(v,i);
			else if (dep[v]<=dep[u]){
				for (int i=u;i!=v;i=fa[i]) q[++cir_tot]=i,mk[i]=1;
				q[++cir_tot]=v,mk[v]=1;
			}
		}
}

int tmp;
void dfs1(int u,int par){
	if (par) tmp++;
	int son=0;
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par&&!mk[v]) dfs1(v,u),son++;
	if (son>1){puts("0"); exit(0);}
}

int main(){
	scanf("%d",&n);
	cnt=1;
	rep (i,1,n) scanf("%d",&a[i]),adde(a[i],i),adde(i,a[i]);
	ans=1;
	rep (i,1,n) if (!vis[i]){
		tot=cir_tot=0,dfs(i,-1);
		if (cir_tot==2&&q[1]==q[2]) cir_tot--;
		if (tot==cir_tot) sum[tot]++;
		else{
			if (a[q[1]]!=q[2]) reverse(q+1,q+1+cir_tot);
			int st=1;
			rep (j,1,cir_tot){
				tmp=0,dfs1(q[j],0),len[j]=tmp;
				if (tmp) st=j;
			}
			int len_2=0;
			for (int j=st%cir_tot+1;;j=j%cir_tot+1){
				len_2++;
				if (len[j]){
					ans=(ll)ans*((len[j]<=len_2)+(len[j]<len_2))%mod;
					len_2=0;
				}
				if (j==st) break;
			}
		}
	}
	rep (i,1,n){
		if (!sum[i]) continue;
		f[0]=1;
		rep (j,1,sum[i]){
			f[j]=f[j-1];
			if (i>1&&(i&1)) f[j]=(f[j]+f[j-1])%mod;
			if (j>1) f[j]=(f[j]+(ll)f[j-2]*(j-1)%mod*i%mod)%mod;
		}
		ans=(ll)ans*f[sum[i]]%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9984