akhauriyash/Code-Regression huggingface dataset:
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = 100001;//TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}
 
LL F[MAXUS];
LL ccnk(LL n, LL k) {
    cout << n << " " << k;
  if (k < 0 || k > n) return 0;
  return F[n] / F[k] / F[n-k];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    int a,b;
    cin>>a>>b;
    if(a%2!=0 &&b%2!=0)
    {
        cout<<"Odd"<<endl;
    }
    else 
    {
        cout<<"Even"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

void m1(){
  int n,k;
  cin >> n >> k;
  int arr[n+5];
  REP(i,n) cin >> arr[i];
  for(int i=k;i<n;++i){
  	if(arr[i] > arr[i-k]) cout << "Yes\n";
    else cout << "No\n";
  }
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 4392
#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;
vector<int> sumF1;
vector<int> sumF2;
vector<int> sumB1;
vector<int> sumB2;
vector<int> X;
int L, N;
int res = 0;
int solve() {

	sumF1.resize(N + 2, 0);
	sumF2.resize(N + 2, 0);
	for (int i = 1; i <= N + 1; i++) {
		sumF1[i] = sumF1[i - 1] + X[i - 1];
	}
	for (int i = 1; i <= N + 1; i++) {
		sumF2[i] = sumF2[i - 1] + sumF1[i];
	}
	reverse(X.begin(), X.end());
	sumB1.resize(N + 2, 0);
	sumB2.resize(N + 2, 0);
	for (int i = 1; i <= N + 1; i++) {
		sumB1[i] = sumB1[i - 1] + X[i - 1];
	}
	for (int i = 1; i <= N + 1; i++) {
		sumB2[i] = sumB2[i - 1] + sumB1[i];
	}
	reverse(X.begin(), X.end());

	/*for (int i = 0; i < N + 1; i++) {
		cerr << X[i] << " ";
	}
	cerr << endl;
	for (int i = 0; i <= N + 1; i++) {
		cerr << sumF2[i] << " ";
	}
	cerr << endl;*/
	int c0 = (N + 1) / 2;
	int l = N % 2;
	int num = N;
	for (int i = 0; i < N; i++) {
		c0 = (N + 1 + i) / 2;
		l = (N + i) % 2;
		int ans = 2 * (sumF2[c0] - sumF2[i]);
		ans += 2 * sumB2[N - c0];
		if (l == 1) {
			ans -= sumF1[c0];
		}
		else {
			ans -= sumB1[N - c0];
		}
		//cerr << i << " " << c0  << " "  << l << " " << ans << endl;
		res = max(res, ans);
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> L >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	X.resize(N + 1);
	X[0] = A[0];
	for (int i = 1; i < N; i++) {
		X[i] = A[i] - A[i - 1];
	}
	X.back() = L - A.back();



	solve();
	reverse(X.begin(), X.end());

	solve();


	cout << res << endl;


}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  string S;
  cin >> S;

  if(S.substr(0,7)=="keyence"||(S.substr(0,6)=="keyenc"&&S.substr(S.size()-1)=="e")||(S.substr(0,5)=="keyen"&&S.substr(S.size()-2)=="ce")||(S.substr(0,4)=="keye"&&S.substr(S.size()-3)=="nce")||(S.substr(0,3)=="key"&&S.substr(S.size()-4)=="ence")||(S.substr(0,2)=="ke"&&S.substr(S.size()-5)=="yence")||(S.substr(0,1)=="k"&&S.substr(S.size()-6)=="eyence")||S.substr(S.size()-7)=="keyence"){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

int main(){
  int64_t n,d,x,y,ans=0;
  cin>>n>>d;
  d=d*d;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    x=x*x;
    y=y*y;
    if(d>=(x+y))
      ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,b) for(int i=0; i<int(b);i++)
#define eb emplace_back

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const MAX_V = 10010;
void stronglyConnectedComponents(Graph const & g, int cmp[MAX_V]){
    int n = g.size();
    Graph rg(n);
    rep(i,n) for(auto & e : g[i]) rg[e.dst].eb(e.dst, e.src, e.weight);
    static int added[MAX_V], visited[MAX_V], ord[MAX_V], S[MAX_V];
    rep(i,n) added[i] = visited[i] = cmp[i] = 0;
    int sz = 0;
    rep(i,n){
        if(visited[i]) continue;
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1];
            visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){
                    S[s++] = dst;
                    pushed = true;
                }
            }
            if(!pushed){
                int t = S[s-1];
                if(!added[t]){
                    added[t] = true;
                    ord[sz++] = t;
                }
                s--;
            }
        }
    }
    rep(i,n) visited[i] = 0;
    int k = 0;
    rep(i,n){
        int u = ord[n-i-1];
        if(visited[u]) continue;
        int s = 0;
        S[s++] = u;
        while(s){
            int v = S[--s];
            visited[v] = true;
            cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(!visited[d]) S[s++] = d;
            }
        }
        k++;
    }
}

int main(){
    int n,m;
    scanf("%d%d", &n,&m);
    Graph g(n);
    rep(i,m){
        int a,b;
        scanf("%d%d", &a,&b);
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        scanf("%d%d", &a,&b);
        printf("%d\n", c[a]==c[b]);
    }
}

Measured memory_bytes: 2416
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            tokenizer = new StringTokenizer(reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    public String nextLine() throws IOException {
        return reader.readLine();
    }
    
}
public class Main{
	public static void main(String args[]) throws IOException{
    	Reader.init();
      	int N=Reader.nextInt();
      	int K=Reader.nextInt();
      	int Q=Reader.nextInt();
      	int P[]=new int[N];
      	Arrays.fill(P, K);
      	
      	for(int i=0;i<Q;i++){
        	int winner=Reader.nextInt();
          	P[winner-1]++;
        }
      
      	for(int i=0;i<N;i++){
        	if(P[i]-Q>0){
            	System.out.println("Yes");
            }
          	else{
            	System.out.println("No");
            }
        }

    }      
}

Measured memory_bytes: 44792
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	foreach (line; stdin.byLine) {
		auto t = line.chomp.to!double / 9.8;
		((4.9 * t^^2 + 5) / 5).ceil.writeln;
	}
}

Measured memory_bytes: 1172
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 50;
char s[MAXN + 5];
int n, k;

int main() {
	read(n), read(k);
	scanf("%s", s + 1);
	s[k] += 32;
	puts(s + 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K;
	cin >> N >> K;
	if(K == 0) {
		cout << 1LL*N*N << "\n";
		return 0;
	}
	cat ans = 0;
	for(int b = K+1; b <= N; b++) {
		int n = N;
		if(n%b >= K) ans++;
		if(n%b != 0) {
			ans += max(0, n%b-K);
			n -= n%b;
		}
		ans += 1LL*(b-K)*(n/b);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
n, m = map(int, input().split())

s = [list(map(int, input().split())) for _ in range(m)]
k = [0] * m
for i in range(m):
    k[i] = s[i][0]
    del s[i][0]
p = list(map(int,input().split()))
ans = 0
for b in range(2 ** n):
    sum = 0
    cnt = [0] * m 
    flag = [False] * m
    for j in range(n):
        if b >> j & 1:
            for k in range(m):
                if (j + 1) in s[k]:
                    cnt[k] += 1
    #print(cnt, b)
    for i in range(m):
        if cnt[i] % 2 == p[i]:
            flag[i] = True
    
    if all(flag[i] == True for i in range(m)):
        """
        print(b)
        print(flag)
        """
        ans += 1
print(ans)

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

inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	
	while (ch<'0'||ch>'9')
	{
		if (ch=='-')  w=-w;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9')
	{
		s=(s<<1)+(s<<3)+(ch^'0');
		ch=getchar();
	}
	return s*w;
}

int main()
{
  ll n;
  cin >> n;//读入 
  
  vector<ll> v(n+1), w(n+1);//把它当成普通数组就可以啦 
  
  for (int i = 1; i <= n; i++)  v[i]=read(),w[i]=read();

  ll MAX_W = 100001LL;//所有询问的L值的最大值 
  vector<vector<ll> > dp(1LL<<10, vector<ll>(MAX_W, 0));//建立dp数组，向量套向量 

  for (ll i = 1; i < 1LL<<10; i++)//预处理出深度在(n/2)向下取整的节点的dp值(一行)，就是经典的01背包 
  {
    if (i > n) break;//如果它不是这棵树的节点，跳出 
    for (ll j = 1; j < MAX_W; j++)
	{
      dp[i][j] = dp[i/2][j];//dp[i/2][j]表示它父亲的dp值；即这个节点不选，直接继承上面的状态 
      if (j - w[i] >= 0) {//如果它是可以通过取该节点与其他一些东西所得到的 
        dp[i][j] = max(dp[i][j], dp[i/2][j-w[i]] + v[i]);
        //用dp[i/2][j-w[i]]+v[i]来更新答案
		//dp[i/2]表示其父节点的dp值。之所以不是dp[i]，是因为这不是无限背包 
      }
    }
  }
  ll query;//询问次数 
  cin >> query;//输入 
 
  for (ll q = 0; q < query; q++)//q次询问 
  {
    ll val, lim;
    val=read(),lim=read();
    if (val < (1LL<<10))//如果它已经被预处理过了，直接打印输出 
	{
      cout << dp[val][lim] << endl;
      continue;//别忘记continue 
    }
    
    ll ans = 0;
    int len = (int)(log2(val)) - 10 + 1;//记录下从len及它自己向上，有多少个节点没有被预处理过 
    for (int i = 0; i < (1<<len); i++)//01枚举上面未被预处理的len个节点的状态，即选或不选(与状压dp有些像) 
    { 
      ll vtemp = 0, wtemp = 0, index = val;
      //vtemp记录下当前被枚举选到的节点的value之和，wtemp同理记录下weight之和，方便转移 
      for (int j = 0; j < len; j++)
	  {
        if ((i>>j) & 1)//对于所有被选择的
		{
          vtemp += v[index];
          wtemp += w[index];
        }//求出vtemp,wtemp 
        index /= 2;//它的父亲 
        if (index < 1LL<<10)//如果index的这个节点已经被预处理过，尝试转移 
		{
          if (lim - wtemp < 0) break;//根本挤不下去，选这些都超过上限limit了，直接跳出 
          ans = max(ans, vtemp + dp[index][lim-wtemp]);
          //全篇最最核心的代码
		  //用vtemp+dp[intex][lim-wtemp]更新答案。即，vtemp表示当前的价值，还要加上之前预处理过的值，就是节点为index，上限为lim-wtemp所能得到的价值和的最大值 
          break;//转移成功，溜掉 
        }
      }
    }
    cout << ans << endl;//打印输出 
  }
  return 0; 
}
//完结撒花 

Measured memory_bytes: 810808
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    if( a % 3 == 0 || b % 3 == 0 ||( a + b ) % 3 == 0 ) cout << "Possible";
    else cout << "Impossible";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using large = long long;
int main() {
    large n, k, q;
    cin >> n >> k >> q;
    auto a = vector<large>(q);
    auto win_count_of = vector<large>(n);
    for (auto &a_i : a) {
        cin >> a_i;
        a_i--;
        win_count_of[a_i]++;
    }

    for (int i = 0; i < n; i++) {
        auto score_i = k - (q - win_count_of[i]);
        cout << (score_i <= 0 ? "No" : "Yes") << "\n";
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	
	int R,G,B,N;
	
	cin >> R >> G >> B >> N;
	
	int tmp;
	int ans = 0;
	
	
	for (int i = 0; i < N/R+1; i++) {
		for (int j = 0; j < N/G+1; j++){
			if((N-i*R-j*G >= 0) && ((N-i*R-j*G)%B ==0)){
				ans++;
				
//	cout << "R:" << i << ",G:" << j << endl;
				
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto & a : A)
    cin >> a;
  sort(A.begin(), A.end());
  if ((0 == N%2) && (1 != A[0]))
  {
    cout << 0;
    return 0;
  }
  else if ((0 != N%2) && (0 != A[0]))
  {
    cout << 0;
    return 0;
  }
  int i = ((0 == N%2) ? 0 : 1);
  int j = ((0 == N%2) ? 1 : 2);
  for (; i < N; i += 2, j += 2)
  {
    if ((j != A[i]) || (j != A[i + 1]))
    {
      cout << 0;
      return 0;
    }
  }
  int cnt = 1;
  for (int k = 0; k < N/2; ++k)
  {
    cnt <<= 1;
    cnt %= 1000000007;
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		//		long ans = Math.max(a * b, a * c);
		long ans = Math.max(a * c, a * d);
		ans = Math.max(ans, b * c);
		ans = Math.max(ans, b * d);
		//		ans = Math.max(ans, c * d);

		System.out.println(ans);
	}

}


Measured memory_bytes: 35728
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 21, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll compatible[N], dp[N][1<<N];

ll f(int man_id, int girls_available) {
    if (man_id < 0) return 1;
    if (dp[man_id][girls_available] != -1) return dp[man_id][girls_available];

    ll ans = 0;
    for (int j = 0; j < N; ++j)
        if ((girls_available & compatible[man_id]) & (1 << j))
            ans = add(ans, f(man_id-1, girls_available & (~(1 << j))));

    return dp[man_id][girls_available] = ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    rep (i, 0, n) rep (j, 0, n) { bool x; cin >> x; compatible[i] |= x << j; }
    memset(dp, -1, sizeof(dp));
    cout << f(n-1, (1<<n)-1) << endl;
    return 0;
}

Measured memory_bytes: 344448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int m, n;
char a[101][101];
int dir[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
bool vis[101][101];
bool in(int x, int y) {
	return x >= 0 && x < m&&y >= 0 && y < n;
}
void dfs(int x, int y, char c) {
	for (int i = 0; i < 4; i++) {
		int tx = x + dir[i][0];
		int ty = y + dir[i][1];
		if (in(tx, ty) && !vis[tx][ty] && a[tx][ty] == c) {
			vis[tx][ty] = 1;
			dfs(tx, ty, c);
		}
	}
}
int main() {
	int t;
	while (cin >> m >> n && (m || n)) {
		memset(vis, 0, sizeof(vis));
		for (int i = 0; i < m; i++)
			cin >> a[i];
		int k = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (!vis[i][j]) {
					vis[i][j] = 1;
					dfs(i, j, a[i][j]);
					k++;
				}
			}
		}
		cout << k << endl;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 3756
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };


int main(void) {
	
	int n;

	cin >> n;

	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<ll> A(n + 1), B(n);
    rep(i, n + 1) cin >> A[i];
    rep(i, n) cin >> B[i];

    ll cnt = 0;
    rep(i, n) {
        if(A[i] <= B[i]) {
            cnt += A[i];
            B[i] -= A[i];
            if(A[i + 1] < B[i]) {
                cnt += A[i + 1];
                A[i + 1] = 0;
            }
            else {
                cnt += B[i];
                A[i + 1] -= B[i];  
            }
        } else {
            cnt += B[i];
            A[i] -= B[i];
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
k=[]
zisyo={}

for i in range(n):
    k.append(list(map(int,input().split())))

for i in range(n):
    for j in range(1,k[i][0]+1):
        if  str(k[i][j]) in zisyo:
            zisyo[str(k[i][j])]+=1
        else:
            zisyo[str(k[i][j])]=1

count=0

for key,val in zisyo.items():
    if val==n:
        count+=1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	ll a,b;
	char s[110];
	cin>>a>>s;
	b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
	cout<<a*b/100<<endl;
}

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

int main() {
    int n; cin >>n;
    vector<int> rate(8,0);
    int r, over3200 = 0;
    for (int i = 0; i < n; i++) {
        cin >> r;
        if(r>=3200) {over3200++;continue;}
        rate[(int)(r/400)]++;
    }
    int ret_min = 0;
    for (int i = 0; i < 8; i++) ret_min += (rate[i]>0) ? 1 : 0;
    if (ret_min==0) {ret_min = 1; over3200--;} // Ohh, I totally forgot.. All person are crazy in AtCoder, in this case.(in1.txt)

    int ret_max = ret_min + over3200; // ??? min(ret_min+over3200, 8);

    cout << ret_min << " " << ret_max << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

paper = [[0] * 10 for x in xrange(10)]

def dropInc(coord, size):
    x, y = coord
    if size == 1:
        paper[y][x] += 1
        if y > 0:
            paper[y-1][x] += 1
        if y < 9:
            paper[y+1][x] += 1
        if x > 0:
            paper[y][x-1] += 1
        if x < 9:
            paper[y][x+1] += 1
    elif size == 2:
        dropInc(coord, 1)
        if y > 0 and x > 0:
            paper[y-1][x-1] += 1
        if x < 9 and y > 0:
            paper[y-1][x+1] += 1
        if x > 0 and y < 9:
            paper[y+1][x-1] += 1
        if x < 9 and y < 9:
            paper[y+1][x+1] += 1
    elif size == 3:
        dropInc(coord, 2)
        if x > 1:
            paper[y][x-2] += 1
        if x < 8:
            paper[y][x+2] += 1
        if y > 1:
            paper[y-2][x] += 1
        if y < 8:
            paper[y+2][x] += 1

for line in sys.stdin.readlines():
    line = line.strip()
    x,y,size = map(int, line.split(","))
    dropInc((x,y), size)

print sum([1 if x == 0  else 0 for y in paper for x in y])
print max([x for y in paper for x in y])

Measured memory_bytes: 5396
import sys
n,y = map(int,input().split())
for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i+5000*j+1000*(n-i-j) == y:
      print("{} {} {}".format(i,j,n-i-j))
      sys.exit()
print("-1 -1 -1")
      

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)


int main(){
    int N, K, A=0, pn, pk;
    cin >> N >> K;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec.at(i);
        pk=max(K, vec.at(i))-min(K, vec.at(i));
        A+=2*(min(vec.at(i), pk));
    }

    cout << A << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 998244353;

int main() {
  int N;cin >> N;
  vint a(N);
  int other=0;
  int cntother=0;
  repeat(i,N){
    cin >> a[i];
    if(other<0) continue;
    if(a[i]!=a[0]){
      if(other==0&&abs(a[0]-a[i])==1){
        other = i;
        cntother++;
      }else if(a[other]==a[i]){
        cntother++;
      }else{
        other = -1;
      }
    }
  }
  bool isok;
  if(other<0){
    isok = false;
  }else if(other == 0){
    isok = (a[0]<=(N/2)||a[0]==N-1);
  }else{
    if(a[0]<a[other]){
      swap(a[0],a[other]);
      cntother = N-cntother;
    }
    int rest = a[0]-cntother;
    isok = rest>0&&rest<=((N-cntother)/2);
  }
  cout << (isok? "Yes":"No" )<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
  long long a,b,v,w,t,le,sp;
  cin >> a >> v ;
  cin >> b >> w ;
  cin >> t;
  le = abs(a-b);
  sp = (v-w)*t;
  if (sp>=le){
    cout << "YES";
  }else{
    cout <<"NO";
  }

}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

class MYCP {
public:
	//数値を標準出力
	static void Print_Int(long long number) {
		std::cout << number << std::endl;
	}

	static void Print_Ints(vector<long long> numbers) {
		std::cout << numbers[0];
		for (int i = 1;i < numbers.size();i++) {
			std::cout << " " << numbers[i];
		}

		std::cout << std::endl;
	}

	static vector<string> MyReadLineSplit(int n) {
		vector<string> str(n);
		for (int i = 0;i < n;i++) {
			std::cin >> str[i];
		}

		return str;
	}

	static vector<long long> ReadInts(long long number) {
		vector<long long> a(number);
		for (int i = 0;i < number;i++) {
			std::cin >> a[i];
		}

		return a;
	}

	//渡された自然数が素数ならtureを返す
	static bool PrimeCheck_Int(long number) {
		if (number < 2)return false;

		for (int i = 2;i*i <= number;i++) {
			if (number%i == 0)return false;
		}

		return true;
	}
};


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long a;
	cin >> a;
	if (a % 2 == 1)a *= 2;
	cout << a;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
Q = int(input())
query = [input().split() for _ in range(Q)]

bit = [[0 for _ in range(26)] for _ in range(N + 1)]



def bit_add(i, s):
    ss = ord(s) - ord("a")
    while i <= N:
        bit[i][ss] += 1
        i += i & - i
def bit_add2(i, s):
    ss = ord(s) - ord("a")
    while i <= N:
        bit[i][ss] += -1
        i += i & - i
        
def bit_sum(i):
    s = [0] * 26
    while i:
        for j in range(26):
            s[j] += bit[i][j]
        i -= i & -i
    return s
for i in range(1, N + 1):
    s = S[i - 1]
    bit_add(i, s)



for x, y, z in query:
    if x == "1":
        y = int(y)
        bit_add2(y, S[y - 1])
        bit_add(y, z)
        S[y - 1] = z
    if x == "2":
        answer = 0
        y, z = int(y) - 1, int(z)
        yy = bit_sum(y)
        zz = bit_sum(z)
        #print(yy)
        #print(zz)
        for i in range(26):
            if zz[i] - yy[i] > 0:
                answer += 1
        print(answer)
    #print(S)
    #print(bit_sum(N))

Measured memory_bytes: 244636
#include<stdio.h>
int a[100];
int main(){
    for(int i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<3;i++){
        int max=0,po;
        for(int u=0;u<10;u++){
            if(a[u]>max){
                max=a[u];
                po=u;
            }
        }
        printf("%d\n",max);
        a[po]=0;
    }

    return 0;
}



Measured memory_bytes: 2108
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, m;
	while(cin >> n >> m) {
		vector<int> imos(n+1);
		REP(i, m) {
			int l, r;
			cin >> l >> r;
			l--;
			imos[l]++;
			imos[r]--;
		}
		REP(i, n) {
			imos[i+1] += imos[i];
		}
		int ans = 0;
		REP(i, n) {
			if(imos[i] == m) {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    char s;
    cin>>s;
    if(s>='a'&&s<='z'){
        cout<<'a';
    }else{
        cout<<'A';
    }
}

Measured memory_bytes: 3588
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Control.Monad
import Data.Char
import Data.List

solve :: VU.Vector Int -> Int -> VU.Vector Bool
solve as k = foldl' step (VU.singleton False) [1..k+1]
    where
        step :: VU.Vector Bool -> Int -> VU.Vector Bool
        step v n = 
            let
                new = VU.foldl' (\b a -> if (n - a >= 0) then (not $ v VU.! (n-a)) || b else b) False as
            in
                VU.snoc v new

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    putStrLn $ if (solve as k) VU.! k then "First" else "Second"

Measured memory_bytes: 2300
from collections import deque
s=input()

d=deque()
for i in range(len(s)):
    if s[i]=="1":
        d.append("1")
    elif s[i]=="0":
        d.append("0")
    else:
        if len(d)!=0:
            d.pop()

L="".join(d)
print(L)

Measured memory_bytes: 9272
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M = [int(x) for x in input().split()]
uf = UnionFind(N)
p = [int(x) for x in input().split()]
for _ in range(M):
  x,y = [int(x) for x in input().split()]
  uf.union(x-1,y-1)
ans = 0
for i in range(N):
  if i+1!=p[i] and uf.same(i,p[i]-1):
    ans +=1
  elif i+1==p[i]:
    ans += 1
print(ans)
  


Measured memory_bytes: 14708
'use strict'

function main(s) {

  s = s.split('\n');
  const a = Number(s[0]);
  const b = Number(s[1]);
  const c = Number(s[2]);
  const d = Number(s[3]);

  const ans = Math.min(a, b) + Math.min(c, d);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w * h / 2;
  int num;
  if (x * 2 == w && y * 2 == h) {
    num = 1;
  } else {
    num = 0;
  }
  printf("%lf %d\n", ans, num);

  return 0;
}


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

using namespace std;
const int N = 2e5+100; 
bool ok[N];
int pen[N];
int main(){
	int n,m;
	cin>>n>>m;
	int x;
	string ve;
	int ans=0,pens=0;
	for(int i=1;i<=m;i++){
		cin>>x>>ve;
		if(ve=="AC"){
			if(!ok[x]) ans++;
			ok[x]=1; 
		}else{
			if(!ok[x]){
				pen[x]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(ok[i]) pens+=pen[i];
	}
	cout<<ans<<' '<<pens<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,d,e,f,g;
  d=0;
  cin>>a>>b;
  int c=b%5000/1000;
  for(int i=c;i<=a;i+=5){
    for(int j=0;j<=a-i;j++){
      if(j*10000+i*1000+(a-i-j)*5000==b){
        d++;
        e=j;
        f=a-i-j;
        g=i;
        break;
      }
    }
      if(d>0){
        break;
      }
  }
  if(d==0){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
  else{
    cout<<e<<" "<<f<<" "<<g<<endl;
  }
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    rep(i, n)
    {
        int a;
        cin >> a;
        for (int j = 1; j <= d; j += a)
        {
            ans++;
        }
    }
    c(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	char sh[20005],sh2[20005];
	scanf("%s%s",sh,sh2);
	sort(sh,sh+strlen(sh));
	sort(sh2,sh2+strlen(sh2));
	if(strcmp(sh,sh2)==0)printf("No\n");
	else if(sh2[strlen(sh2)-1]>sh[0])printf("Yes\n");
	else if(strlen(sh)>strlen(sh2))printf("No\n");
	else
	{
		int a[27],b[27];
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i=0;i<strlen(sh);i++)
			a[sh[i]-97]++;
		for(int i=0;i<strlen(sh2);i++)
			b[sh2[i]-97]++;
		for(int i=0;i<27;i++)
		{
			if(a[i]==strlen(sh))
			{
				for(int j=0;j<27;j++)
					if(b[j]==strlen(sh2))
					{
						printf("Yes\n");
						return 0;
					}
			}
		}
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize
    }

    println!(
        "{}",
        match n % 10 {
            3 => "bon",
            0 | 1 | 6 | 8 => "pon",
            _ => "hon"
        }
    );
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  vector<int> t(3);
  for (int i = 0; i < 3; i++) cin >> t[i];
  sort(t.begin(), t.end());
  cout << t[0] * t[1] / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s, t;
    cin>>s>>t;
    ll ans = INF;
    for(ll i=0;i<s.size()-t.size()+1;++i){
        ll sum = 0;
        for(ll j=0;j<t.size();++j){
            if(s[i+j] != t[j]){
                sum++;
            }
        }
        ans = min(ans, sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4624
#include <bits/stdc++.h>
#define N 200005
using namespace std;
typedef long long ll;
ll n,a[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],a[i]-=i;
    sort(a+1,a+n+1);
    ll mid=n/2,b[3]={a[mid],a[mid+1],a[mid-1]},ans=1e18;
    for(int i=0;i<=2;i++){
        ll cnt=0;
        for(int j=1;j<=n;j++)
            cnt+=abs(a[j]-b[i]);
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5132
import java.util.Scanner;

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

        int T = sc.nextInt();
        int X = sc.nextInt();

        System.out.println(solve(T, X));

        sc.close();
    }

    static double solve(int T, int X) {
        return (double) T / X;
    }
}

Measured memory_bytes: 35832
package main

import(
	"fmt"
)

type bulb struct{
	k,p int
	switches [10]bool
}

func isOn(b bulb, s int)bool{
	sum:=0
	for i:=0;s>0;i++{
		r:=s%2
		if r==1{
			if b.switches[i]{
				sum++
			}
		}
		s/=2
	}
	return (sum%2)==b.p
}

func isAllOn(bs []bulb, s int)bool{
	for i:=0;i<len(bs);i++{
		if !isOn(bs[i],s){
			return false
		}
	}
	return true
}

func main(){
	var n,m int
	fmt.Scanln(&n,&m)
	bulbs:=make([]bulb,m)
	for i,t:=0,0;i<m;i++{
		fmt.Scan(&bulbs[i].k)
		for j:=0;j<bulbs[i].k;j++{
			fmt.Scan(&t)
			bulbs[i].switches[t-1]=true
		}
	}
	for i,t:=0,0;i<m;i++{
		fmt.Scan(&t)
		bulbs[i].p=t
	}
	ans:=0
	for s:=0;s<(1<<uint(n));s++{
		if isAllOn(bulbs,s){
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 3e5 + 5;
int t;

int main()
{
	//freopen("in.txt", "r", stdin);
	unordered_map<int, int> mp;
	f(i, 1, 100)
	{
		f(j, 1, 100)
		{
			if (i*i + j * j > 10000)continue;
			f(k, 1, 100)
			{
				if (i*i + j * j+k*k > 10000)continue;
				mp[i*i + j * j + k * k + i * j + j * k + i * k]++;
			}
		}
	}
	int n;
	while (cin >> n)
	{
		f(i, 1, n)
		{
			cout << mp[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  string s;
  bool flag=true;
  cin >> s;
  int l=s.size();
  sort(s.begin(),s.end());
  for(int i=1;i<l;i++){
    if(s[i]==s[i-1]){
      flag=false;
    }
  }
  if(flag) cout << "yes"<<endl;
  else cout <<"no"<<endl;
}


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

int main()
{
   int n;
   cin>>n;
   for(int i=n;;i++)
   {
      int k=i;
      int a=k%10;
      k/=10;
      int b=k%10;
      k/=10;
      int c=k%10;
      k/=10;
      if(a==b&&b==c)
      {
          cout<<c<<b<<a<<endl;
          return 0;
      }
   }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
int main(void){
    int x;
    cin >> x;

    int ans;
    if (x < 600) ans = 8;
    else if (x < 800) ans = 7;
    else if (x < 1000) ans = 6;
    else if (x < 1200) ans = 5;
    else if (x < 1400) ans = 4;  
    else if (x < 1600) ans = 3;
    else if (x < 1800) ans = 2;
    else if (x < 2000) ans = 1;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a,b,c;
    // 整数の入力
    scanf("%d %d %d", &a, &b, &c);
	if(a+b == c || b+c == a || a+c == b)
    {
    	printf("Yes");
    }
  	else
    {
      printf("No");
  	}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;
using Graph = vector<vector<int>>;

int main(){
    int N,M;cin>>N>>M;
    Graph G(N);
    for(int i=0;i<M;i++){
        int A,B;cin>>A>>B;A--;B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    queue<int> que;
    vector<bool> seen(N);
    int ans = 0;
    for(int i=0;i<N;i++){
        int max = 1;
        if(seen[i]) continue;
        else{
            que.push(i);
            seen[i] = true;
            while(que.size()){
                int p = que.front();que.pop();
                for(auto v:G[p]){
                    if(seen[v]) continue;
                    else{
                        max++;
                        que.push(v);
                        seen[v] = true;
                    }
                }
            }
        }
        if(max>ans) ans = max;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14888
import Data.List
import Control.Monad
main=do
 n<-readLn
 s<-group.sort<$>replicateM n getLine
 m<-readLn
 t<-group.sort<$>replicateM m getLine
 print$maximum$[x|i<-s,j<-t,let x = if(head i)==(head j)then((length i)-(length j))else if not (elem (head i) (map head t))then length i else 0]++[0]

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define mod 998244353
#define maxn 305
#define maxa 90005
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,a[maxn],tot,f[maxa],g[maxa];
int main(){
  n = getint();
  for(int i = 1;i <= n;i++) a[i] = getint(), tot += a[i];
  g[0] = f[0] = 1;
  for(int i = 1;i <= n;i++){
    for(int j = tot;j >= 0;j--){
      f[j] = (f[j] << 1) % mod;
      if(j >= a[i]){
        (f[j] += f[j - a[i]]) %= mod;
        (g[j] += g[j - a[i]]) %= mod;
      }
    }
  }
  ll ans = 1;
  for(int i = 1;i <= n;i++) ans = ans * 3ll % mod;
  int lim = (tot >> 1);
  if(!(tot & 1)) lim--;
  for(int j = lim + 1;j <= tot;j++){
    ans = (ans - (ll)f[j] * 3ll % mod + mod) % mod;
  }
  if(!(tot & 1)){
    ans = (ans + (ll)g[lim + 1] * 3ll % mod) % mod;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 896