akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = (int) 1e6 + 10;
		long[] cnt = new long[M];
		for(int i=0;i<N;i++) cnt[A[i]]++;
		
		for(int i=1;i<M;i++){
			if(cnt[i] == 0) continue;
			for(int j=i+i;j<M;j+=i){
				cnt[j] += cnt[i];
			}
		}
		
		long[] cnt2 = new long[M];
		for(int i=0;i<N;i++) cnt2[A[i]]++;
		
		int ans = 0;
		for(int i=0;i<M;i++){
			if(cnt2[i] == 1 && cnt[i] == 1){
				ans++;
			}
		}
		Console.WriteLine(ans);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n%10==3){
        cout<<"bon";
    }else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout<<"pon";
    }else{
    cout<<"hon";
    }


    return 0;
}




Measured memory_bytes: 3568
ri = lambda: map(int, raw_input().split())
def pi(a): print (' '.join(map(str, a)))

h, w = ri()
n = input()
a = ri()

g = [[i + 1] * x for i, x in enumerate(a)]
g = [x for l in g for x in l]

for i in xrange(h):
    l = g[i*w:i*w+w]
    if i & 1:
        l = l[::-1]
    pi(l)


Measured memory_bytes: 33052
import java.util.Scanner;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int[] gcdl = new int[n];
        int[] gcdr = new int[n];
        gcdl[0] = a[0];
        for (int i = 1; i < gcdr.length; i++) {
            gcdl[i] = gcd(gcdl[i - 1], a[i]);
        }
        gcdr[n - 1] = a[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            gcdr[i] = gcd(gcdr[i + 1], a[i]);
        }

        // 端を使わない場合
        int max = Math.max(gcdr[1], gcdl[n - 2]);
        for (int i = 0; i < gcdr.length - 2; i++) {
            int ans = gcd(gcdl[i], gcdr[i + 2]);
            max = Math.max(ans, max);
        }
        System.out.println(max);

    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }

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

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


Measured memory_bytes: 51096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=55;
//i_am_noob
int a,b,k;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> k;
	if(k<=a) print2(a-k,b);
	else if(k<=a+b) print2(0,a+b-k);
	else print2(0,0);
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int c = 1;
  string t = s.substr(0, 1);
  for (int i = 1; i < s.size(); i++) {
    string d = s.substr(i, 1);
    if (d != t) {
      c++;
      t = d;
    }
    else if (i != s.size() - 1) {
      c++;
      i++;
      t = s.substr(i, 2);
    }
  }
  cout << c << '\n';
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

int N;
struct S {
  char g[MAX_N][MAX_N];
  int x, y;
  int cost;
  bool operator < (const S &s) const {
    if(x != s.x) return x < s.x;
    if(y != s.y) return y < s.y;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
	if(g[i][j] != s.g[i][j]) return g[i][j] < s.g[i][j];
      }
    }
    return false;
  }
  void show() {
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
	cout << g[i][j];
      }
      cout << endl;
    }
    cout << endl;
  }
};

bool isAllFree(const S &s) {
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(s.g[i][j] == '#') return false;
    }
  }
  return true;
}

void trance(const S &s, S &t, int x, int y) {
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(j == x && i == y) {
	t.g[i][j] = '.';
	continue;
      }
      int cnt = 0;
      for(int k = 0; k < 8; ++k) {
	int nx = j + dx[k];
	int ny = i + dy[k];
	if(nx < 0 || nx >= N) continue;
	if(ny < 0 || ny >= N) continue;
	if(nx == x && ny == y) ++cnt;
	if(s.g[ny][nx] == '#') ++cnt;
      }
      if(s.g[i][j] == '.') {
	if(cnt == 3) t.g[i][j] = '#';
	else t.g[i][j] = '.';
      } else {
	if(cnt == 2 || cnt == 3) t.g[i][j] = '#';
	else t.g[i][j] = '.';
      }
    }
  }
}

int solve(S s) {
  queue<S> que;
  set<S> vis;
  que.push(s);
  vis.insert(s);
  while(!que.empty()) {
    s = que.front();
    que.pop();
    if(isAllFree(s)) return s.cost;
    for(int i = 0; i < 8; ++i) {
      S t;
      t.x = s.x + dx[i];
      t.y = s.y + dy[i];
      t.cost = s.cost + 1;
      if(t.x < 0 || t.x >= N) continue;
      if(t.y < 0 || t.y >= N) continue;
      if(s.g[t.y][t.x] == '#') continue;
      trance(s, t, t.x, t.y);
      if(vis.find(t) != vis.end()) continue;
      vis.insert(t);
      que.push(t);
    }
  }
  return -1;
}

int main() {
  while(cin >> N && N) {
    S s;
    s.cost = 0;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
	cin >> s.g[i][j];
	if(s.g[i][j] == '@') {
	  s.g[i][j] = '.';
	  s.x = j;
	  s.y = i;
	}
      }
    }
    cout << solve(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}
 
li mmi(li a){return power(a,mod-2);}
 
li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n,m;
char c[55][55];
int dis[55][55];
int vis[55][55];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};

typedef pair<int,pair<int,int> > pipii;

void dijkstra(int x,int y){
	priority_queue<pipii,vector<pipii>,greater<pipii> > pq;
	pq.push(make_pair(1,make_pair(x,y)));
	memset(dis,-1,sizeof(dis));
	if(c[x][y]=='#') return ;
	while(!pq.empty()){
		auto p=pq.top();
		pq.pop();
		int x=p.second.first;
		int y=p.second.second;
		int w=p.first;
		if(x<1 or x>n or y<1 or y>m) continue;
		if(vis[x][y]) continue;
		vis[x][y]=1;
		dis[x][y]=w;
		for(int i=0;i<4;i++){
			int ro=dx[i]+x;
			int co=dy[i]+y;
			if(!vis[ro][co] and c[ro][co]=='.'){
				pq.push(make_pair(1+w,make_pair(ro,co)));
			}
		}
	}
}

void solve(){
	cin>>n>>m;
	int cnt=0;
	for(int i=0;i<55;i++){
		for(int j=0;j<55;j++){
			c[i][j]='#';
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c[i][j];
			if(c[i][j]=='.'){
				cnt++;
			}
		}
	}
	dijkstra(1,1);
	if(dis[n][m]==-1) cout<<"-1";
	else cout<<cnt-dis[n][m];
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int b = sc.nextInt();
			int r = sc.nextInt();
			int g = sc.nextInt();
			int c = sc.nextInt();
			int s = sc.nextInt();
			int t = sc.nextInt();
			if((b|r|g|c|s) == 0) break;
			long cnt = 100;
			cnt += b*15 + 5*b*15;
			cnt += r*15 + 3*r*15;
			cnt += g*7;
			cnt += c*2;
			cnt += 3*s;
			cnt -= t*3;
			cnt += 5*b+3*r;
			System.out.println(cnt);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int y = sc.nextInt() / 1000;
		
		boolean flag = true;
		loop : for(int i = 0; i <= n; i++) {
			for(int j = 0; j <= n - i; j++) {
				int k = n - i - j;
				if(i * 10 + j * 5 + k == y) {
					System.out.printf("%d %d %d\n", i, j, k);
					flag = false;
					break loop;
				}
			}
		}
		
		if(flag) {
			System.out.println("-1 -1 -1");
		}
	}
}

Measured memory_bytes: 22996
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let count = Int(readLine()!)!
    var ary: Set = Set<String>()
    for _ in 1...count {
        ary.insert(readLine()!)
    }
    print(ary.count)
}
main()

Measured memory_bytes: 25196
import java.util.Scanner;

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

        if(A==B&&A!=C){
            System.out.println("Yes");
        }else if(B==C&&B!=A){
            System.out.println("Yes");
        }else if(A==C&&A!=B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int x;
  cin >> x;
  cout << 1 - x << '\n';

  return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main{
	static 	long search(long[] lst,long key){
		int left = 0 ;
		int right = lst.length;
		int mid ;
		while(left < right){
			mid = (left + right) / 2 ;
			if(lst[mid] == key) return mid;
			else if(lst[mid] < key)left = mid +1 ;
			else if(key < lst[mid])right = mid;
		}
		return -1 ;
	}
	
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    
	    int n=sc.nextInt();
	    long[] lst = new long[n];
	    for(int i=0;i<n;i++)lst[i]=sc.nextLong();
	    
	    int q=sc.nextInt();
	    int sum=0;
	    
	    for(int i=0;i<q;i++){
	        if(search(lst,sc.nextLong())>=0)sum++;
	    }
	    
	    System.out.println(sum);
	}
}


Measured memory_bytes: 80168
#include<bits/stdc++.h>
using namespace std;
int sum(int x){
    int s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    return s;
}
int main() {
    int n;
    cin>>n;
    cout<<(n%sum(n)==0 ? "Yes":"No")<<endl;
}

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

const int MAXN = 200005;

long long a[MAXN];
long long s[MAXN], c[MAXN];
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (int i = 1; i <= n; i++) s[i] = s[i-1]+a[i];
	for (int i = n; i >= 1; i--) c[i] = c[i+1]+a[i];
	long long ans = 2e10;
	for (int i = 1; i < n; i++) ans = min(ans, abs(s[i]-c[i+1]));
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> >
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------------head--------------------------------------

const int inf=0x3f3f3f3f;
const int N=100005,M=100005,mod=1e9+7;
inline void ch(int &x,int y){x=(x+y)%mod;}
inline int exp(int x,int y,int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,ans;
vi g[N];

inline pii dfs(int x,int F=0){
	int b1=0,b2=0,son=0;
	for(int y:g[x]){
		if(y==F) continue;
		pii tmp=dfs(y,x);
		b1+=tmp.FF;b2+=tmp.SS;
		son++;
	}
	if(!son) return mp(0,0);
	if(b1==son){
		if(son==1&&!b2) return mp(1,0);
		return mp(1,1);
	}
	else{
//		debug(x-1);
		if(son==1) return mp(0,0);
		ans+=son-b1-1;
		return mp(1,0);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		x++;y++;
		g[x].pb(y);g[y].pb(x);
	}
	for(int i=1;i<=n;i++)
		if(g[i].size()==1){
			if(!dfs(g[i][0],i).SS) ans++;
			break;
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) { return power(x, MOD - 2); }

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

ll multiChoose(int n, int k) {
  if (n == 0 && k == 0) {
    return 1;
  } else {
    return choose(n + k - 1, k);
  }
}

int main() {
  initFact(300000);
  int N;
  ll M;
  while (cin >> N >> M) {
    ll res = 1;
    for (ll p = 2; p * p <= M; p++) {
      int e = 0;
      while (M % p == 0) {
        ++e;
        M /= p;
      }
      res = (res * multiChoose(e + 1, N - 1)) % MOD;
    }
    if (M != 1) {
      res = (res * multiChoose(1 + 1, N - 1)) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let (n, m):(u32, u32) = read_tuple2();
    let routes:Vec<(u32, u32)> = (0..m).map(|_|read_tuple2()).collect();
    let mut route_maps = HashMap::new();
    for (from, to) in routes {
        let mut ent =
            route_maps.entry(from).or_insert(LinkedList::new());
        (*ent).push_back(to);
        let mut ent =
            route_maps.entry(to).or_insert(LinkedList::new());
        (*ent).push_back(from);
    }
    let mut snd = LinkedList::new();
    for i in route_maps.entry(1).or_insert(LinkedList::new()) {
        if *i == n {
            println!("POSSIBLE");
            return;
        }
        snd.push_back(*i);
    }
    for i in snd {
        for j in route_maps.entry(i).or_insert(LinkedList::new()) {
            if *j == n {
                println!("POSSIBLE");
                return;
            }
        }
    }
    println!("IMPOSSIBLE");
}



Measured memory_bytes: 25884
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
int result = 0;

void dfs(const Graph &G, int v) {
  seen[v] = true; // v を訪問済にする
  
  bool all_visited = true;
  for (int i = 1; i <= seen.size()-1; i++) {
    if (seen[i] == false) {
      all_visited = false;
    }
  }
  if (all_visited) {
    result++;
    return;
  }
  
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) { 	
    if (seen[next_v]) continue; // next_v が探索済だったらスルー
    dfs(G, next_v); // 再帰的に探索
    seen[next_v] = false; // next_v を未訪問にする
  }
}

int main() {
  // 頂点数と辺数
  int N, M; cin >> N >> M;

  // グラフ入力受取 (ここでは無向グラフを想定)
  Graph G(N+1);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // 頂点 1 をスタートとした探索
  seen.assign(N+1, false); // 全頂点を「未訪問」に初期化
  dfs(G, 1);

  cout << result;
}

Measured memory_bytes: 256
def abc079_c():
    n = list(map(int, input()))
    a = n[0]
    for b in [n[1], -n[1]]:
        for c in [n[2], -n[2]]:
            for d in [n[3], -n[3]]:
                if a + b + c + d == 7:
                    op1 = ["+", "-"][b < 0]
                    op2 = ["+", "-"][c < 0]
                    op3 = ["+", "-"][d < 0]
                    print(a, op1, abs(b), op2, abs(c), op3, abs(d), "=7", sep="")
                    return 0


abc079_c()

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

int main() {
  int n, d;
  cin >> n >> d;
  
  int sum = 1, i = 1;
  
  while (n > (2*d + 1) * i){
    sum ++;
    i++;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
  n = int(input())
  A = list(map(int, input().split()))
  L = [(a, i+1) for i, a in enumerate(A)]
  L.sort(reverse=True)
  dp = [[-1]*(n+1) for _ in range(n+1)]
  dp[0][0] = 0
  for i in range(n+1):
    for j in range(n+1-i):
      a, idx = L[i+j-1]
      if i:
        dp[i][j] = max(dp[i][j], dp[i-1][j]+a*(idx-i))
      if j:
        dp[i][j] = max(dp[i][j], dp[i][j-1]+a*(n+1-j-idx))
  ans = 0
  for i in range(n+1):
    ans = max(ans, dp[i][n-i])
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 124812
//----------------------------------------------------------------------
#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 Graph = vector<vector<int>>;

bool check(int i) {
    int a = 2;
    map<int, int> mp;
    while(i > 1) {
        if(i % a == 0) {
            i /= a;
            mp[a]++;
        }else {
            a++;
        }
    }
    int rep = 1;
    for(auto v : mp) {
        rep *= v.second + 1;
    }
    return rep == 8;
}

int main(void) {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2) {
        if(check(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] num = {0, 10, 100, 1000, 10000, 100000};
        int[] cnt = {0, 9, 10, 909, 910, 90909};

        int i = digitCnt(n);
        if (i % 2 == 0) {
            System.out.println(cnt[i-1]);
        } else {
            System.out.println(cnt[i-1] + n - num[i-1]);
        }
    }

    static int digitCnt(int n) {
        int cnt = 0;
        while (n >= 10) {
            n /= 10;
            cnt++;
        }

        return cnt+1;
    }
}

Measured memory_bytes: 23764
#include<iostream>

using namespace std;

int n, x, y;
string s;

int main () {
	cin >> n >> s;
	for (int i=0; i<n; i++) {
		if (s[i]==')') {
			if (y>0) {
				y--;
			} else {
				x++;
			}
		} else {
			y++;
		}
	}
	for (int i=0; i<x; i++) {
		cout << '(';
	}
	cout << s;
	for (int i=0; i<y; i++) {
		cout << ')';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;






int main(void) {
    ll N, A, B;
    cin >>N>>A>>B;
    
    cout << min(A, B) << " " << max(B-N+A, 0) << endl;
    
    
    
    
}

























Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, T, c, t, i, ans = 1001;
	scanf("%d%d", &N, &T);
	for(i = 0; i < N; i++){
		scanf("%d%d", &c, &t);
		if(t <= T && c < ans){
			ans = c;
		}
	}
	if(ans > 1000){
		printf("TLE\n");
	}
	else{
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
use std::io;


/// https://beta.atcoder.jp/contests/abc081/tasks/abc081_b
fn main() {
    let _ = read_one::<usize>();
    let an = read::<usize>().iter()
        .map(|i| i.trailing_zeros())
        .min().unwrap();
    println!("{}", an);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int calcIndex(int n, vector<int>& target)
{
    int index=1;
    vector<int> v;
    for (int i=1; i<=n; i++) v.push_back(i);

    do {
        bool same = true;
        for(int i =0; i<n; i++) {
            if (v[i] != target[i]) {
                same =false;
                break;
            }
        }
        if (same) break;
        index++;
    } while (next_permutation(v.begin(), v.end()));
    return index;
}

int main() {
    // input, ready
    int N;
    vector<int> P,Q;
    cin >> N;
    P.resize(N);
    Q.resize(N);
    for (int i=0; i<N; i++) cin >> P.at(i);
    for (int i=0; i<N; i++) cin >> Q.at(i);

    // resolve

    // output
    cout << abs(calcIndex(N, P)-calcIndex(N, Q));

    return 0;
}

Measured memory_bytes: 256
#素因数分解
#factorization(2016)=[[2, 5], [3, 2], [7, 1]]の形で出力
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int((n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
p=10**9+7
fli=[1]*(n+1)
for i in range(2,n+1):
  f=factorization(i)
  for j in range(len(f)):
    fli[f[j][0]]+=f[j][1]
ans=1
for i in range(n+1):
  ans=ans*fli[i]%p
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define sync()      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileIO()    freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define F           first
#define S           second
#define ers         erase
#define ins         insert
#define db          pop_back
#define pb          push_back
#define df          pop_front
#define pf          push_front
#define SZ(x)       ((ll)x.size())
#define sqr(x)      (x)*(x)
#define Blz(x)      __builtin_clz(x)
#define Brz(x)      __builtin_ctz(x)
#define Bones(x)    __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define kill(x)     return cout<<x,0
#define dbgp(x)     cerr<< #x << " = " << x.F << ", " << x.S << endl
#define dbg(x)      cerr<< #x << " = " << x << endl
#define ddbg(i,x)   cerr<< #i << " = " << i << " / ", dbg(x[i])
#define tdbg(i,E,x) cerr<< #i << " = " << i << " / ", ddbg(E,x[i])
typedef long long                                    ll;
typedef long double                                  ld;
typedef unsigned short int                           usi;
typedef pair<long long,bool>                         plb;
typedef pair<long long,long long>                    pll;
typedef pair<int,int>                                pii;
typedef string                                       str;
typedef priority_queue<ll>                           maxheap;
typedef priority_queue<ll,vector<ll>,greater<ll>>    minheap;
typedef priority_queue<pll,vector<pll>,greater<pll>> djq;
const ll maxn=2e5+10, wax=20, inf=4e18, mod=1e9+7; const ld pi=3.14159265359, eps=1e-9;
int main(){
    sync();
    ll a,b; cin>>a>>b;
    cout<<(b%a==0 ? a+b: b-a);
    return 0;
}
/**

 (                            )   (   )
 )\ )             (      )  ( /(  () /(
(()/(  (  (    (  )\  ( /(  )\()) )\ ())
 /(_))_)  )\   )\((_) )(_))(_)\) ((_)(_)
(_)) __| ((_) ((_)| |((_)_)| |(_)| |_| |
  | (_ |/ _ \/ _ \| |/ _` || / / |  _  |
   \___|\___/\___/|_|\__,_||_\_\ |_| |_|

I'm burning in rage and hatred...
**/


Measured memory_bytes: 256
import math

H, W, D = map(int, input().split())

coordinate = [[0, 0] for _ in range(H*W+1)]  # coordinate(n) = [nのi座標, nのj座標]
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        coordinate[A[j]] = [i, j]

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def dist(coord1, coord2):
    return int(math.fabs(coord1[0] - coord2[0]) + math.fabs(coord1[1] - coord2[1]))


imos = []
imos.append([])
for d in range(1, D+1):
    lst = [0]
    while d + D <= H * W:
        distance = dist(coordinate[d], coordinate[d + D])
        lst.append(distance)
        d += D
    imos.append(lst)

for d in range(1, D+1):
    for i in range(len(imos[d])-1):
        imos[d][i+1] += imos[d][i]

for q in range(Q):
    d = L[q] % D
    if d == 0:
        print(imos[D][int(R[q] / D) - 1] - imos[D][int(L[q] / D) - 1])
    else:
        print(imos[d][int(R[q] / D)] - imos[d][int(L[q] / D)])

Measured memory_bytes: 30624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans;}
   base *= base;pow/=2;}return ans;}
ll expo1(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}   
ll inv(ll x){return expo1(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){if(k == 0) return 1LL;
    ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

ll wt[123456], vis[123456];

int main(){
    int n, w;
    cin >> n >> w;
    vector <ll> W(n), V(n);
    for(int i = 0; i < n; i++) cin >> W[i] >> V[i];
    vis[0] = 1;
    ll ans = 0;
    for(int i = 1; i <= 1e5; i++) wt[i] = 1e9+1;
    for(int i = 0; i < n; i++){
        for(int j = 1e5; j >= 0; j--){
            if(vis[j]){
               wt[j+V[i]] = min(wt[j+V[i]],wt[j]+W[i]);
               vis[j+V[i]] = 1;
            
            }
        }
    }
    
    for(int i = 1e5; i >= 0; i--){
       if(wt[i] <= w){
           cout << i;
           return 0;
       }
    }
    
}

Measured memory_bytes: 1792
import collections
H, W, M = map(int, input().split())

h, w = [0]*M, [0]*M
dic = set()
for i in range(M):
    h[i], w[i] = map(int, input().split())
    dic.add((h[i],w[i]))

counter = collections.Counter(h)
h_max = max(counter.values())
mode_h = [key for key , value in counter.items() if value == h_max]
counter = collections.Counter(w)
w_max = max(counter.values())
mode_w = [key for key , value in counter.items() if value == w_max]

for i in mode_h:
    for j in mode_w:
        if (i,j) not in dic:
            print(h_max+w_max)
            exit()

print(h_max+w_max-1)



Measured memory_bytes: 93520
import numpy as np


def weight(n, hh):
    weights = np.zeros(n).astype(int)
    weights[0] = 0
    if n==1:
        return weights[0]
    weights[1] = np.abs(hh[1] - hh[0])
    if n==2:
        return weights[1]
    # weights[2] = min(np.abs(hh[2] - hh[1]) + np.abs(hh[1] - hh[0]), np.abs(hh[2] - hh[0]))

    for k in range(2, n):
      weights[k] = min(weights[k-2] + np.abs(hh[k] - hh[k-2]), weights[k-1]+ np.abs(hh[k] - hh[k-1]))
    return weights[n-1]


n = int(input())
svals = input()
hh = np.array(list(map(int, svals.rstrip(' ').split(' '))))
print(weight(n, hh))


Measured memory_bytes: 38708
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=1e18;
const ll mod=(ll)1e9+7;


void solve(){
	int n,W,w,v;
	cin>>n>>W;
	vector<vector<ll>>dp(2,vector<ll>(100001,inf));
	int t=0;
	dp[1][0]=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>w>>v;
		for (int j = 0; j < 100001 ; ++j)
		{
			dp[t][j]=min(dp[!t][j],j>=v?w+dp[!t][j-v]:inf);
		}
		t=(!t);
	}
	int ans=0;
	for (int i = 0; i < 100001; ++i)
	{
		if(W>=dp[!t][i])
		ans=max(ans,i);
	}
	cout<<ans;

}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}


Measured memory_bytes: 2560
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = []
l.append(b-a)
l.append(c-a)
l.append(d-a)
l.append(e-a)
l.append(c-b)
l.append(d-b)
l.append(e-b)
l.append(d-c)
l.append(e-c)
l.append(e-d)

if max(l) <= k:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 9008
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
 
using namespace std;
 
const int MAXN=2e5;
const int INF=1e9;
struct node
{
	int x,y,l,r;
	friend bool operator <(const node a,const node b)
	{
		return a.x>b.x;
	}
};
priority_queue <node> ans;
int f[4*MAXN][2]; 
int a[MAXN],id[MAXN]; 
void build(int root,int left,int right)
{
	if (left==right)
	{
		if (left&1)
		{
			f[root][1]=a[left],f[root][0]=INF; 
		}
		else
		{
			f[root][0]=a[left],f[root][1]=INF;
		}
		return ;
	}
	int mid=(left+right)>>1;
	build(2*root,left,mid);
	build(2*root+1,mid+1,right);
	f[root][1]=min(f[2*root][1],f[2*root+1][1]);
	f[root][0]=min(f[2*root][0],f[2*root+1][0]); 
}	
int query(int root,int left,int right,int qleft,int qright,bool p)
{
	if (left>=qleft && right<=qright)
	{
		if (p)
		{
			return f[root][1];
		}
		else
		{
			return f[root][0];
		}
	}
	int mid=(left+right)>>1;
	if (qright<=mid)
	{
		return query(2*root,left,mid,qleft,qright,p);
	}
	else if (qleft>mid)
	{
		return query(2*root+1,mid+1,right,qleft,qright,p);
	}
	else
	{
		int ans1,ans2;
		ans1=query(2*root,left,mid,qleft,mid,p);
		ans2=query(2*root+1,mid+1,right,mid+1,qright,p);
		return min(ans1,ans2);
	}
}
 
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		id[a[i]]=i;
	}
	build(1,1,n);
	int x=query(1,1,n,1,n,1);
	int y=query(1,1,n,id[x]+1,n,0);
	node q;
	q.l=1,q.r=n,q.x=x,q.y=y;
	ans.push(q);
	for (int i=2;i<=n/2;i++)
	{
		q=ans.top();
		ans.pop();
		int nx=id[q.x];
		int ny=id[q.y];
		node now;
		if (q.l<nx)
		{
			bool p=q.l&1;
			int x=query(1,1,n,q.l,nx-1,p);
			int y=query(1,1,n,id[x]+1,nx-1,p^1);
			now.l=q.l;
			now.r=nx-1;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		if (nx+1<ny)
		{
			bool p=(nx+1)&1;
			int x=query(1,1,n,nx+1,ny-1,p);
			int y=query(1,1,n,id[x]+1,ny-1,p^1);
			now.l=nx+1;
			now.r=ny-1;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		if (ny<q.r)
		{
			bool p=(ny+1)&1;
			int x=query(1,1,n,ny+1,q.r,p);
			int y=query(1,1,n,id[x]+1,q.r,p^1);
			now.l=ny+1;
			now.r=q.r;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		printf("%d %d ",q.x,q.y);
	}
	while (!ans.empty())
	{
		node now=ans.top();
		ans.pop();
		printf("%d %d ",now.x,now.y);
	}
    return 0;
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;
    int ans=INF;
    rep(i,s.size()-t.size()+1){
        int x=0;
        rep(j,t.size()){
            if(s[i+j]!=t[j])x++;
                    //cout<<i+j;
        }

        ans=min(ans,x);
    }
    cout<<ans<<endl;

    



}

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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
  long long n;
  cin >> n;
  if (n % 2 == 1) {
	  cout << 0 << endl;
	  return 0;
	}
  long long num5 = 5;
  long long cnt5 = 0;
  while (num5 <= n) {
	  cnt5 += (n / num5) / 2;
	  num5 *= 5;
	}
  cout << cnt5 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

int main(){
fastio();


     int n;
     cin>>n;
     map<string,int>mp;

     for(int i=0;i<n;i++)
     {
         string str;
         cin>>str;
         mp[str]++;
     }

     cout<<"AC x "<<mp["AC"]<<endl;
          cout<<"WA x "<<mp["WA"]<<endl;
               cout<<"TLE x "<<mp["TLE"]<<endl;
                    cout<<"RE x "<<mp["RE"]<<endl;










return 0;
}



Measured memory_bytes: 3664
import java.util.Scanner;

class Main{
	//この問題の気持ち的にXORする数字（A_1からA_Nまでの数字）の各桁のビットを見ておき、その立っているか/立っていないかの数を調べていけばよさそう
	//XOR　は　11->0 10->1 01->1 00->0
	static int[] bits=new int[63];
	public static void main(String[] args) {
		for(int i=0; i<63; i++) {
			bits[i]=0;
		}
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long K=sc.nextLong();
		//オーバーフローに注意
		long[] uketori=new long[N];
		for(int i=0; i<N; i++) {
			uketori[i]=sc.nextLong();
			calcbit(uketori[i]);
		}
		long[] suji=new long[62];
		suji[0]=1;
		for(int i=1; i<62; i++) {
			suji[i]=suji[i-1]*2;
		}
		long ans=0;
		for(int i=61; i>=0; i--) {
			if(bits[i]*2>N) {		//XORする数字それぞれを見ていって、ビットが半分以上たっていないなら解のビットを立たせない
									//立っているものと立っていないものが同数のときは立たせないほうが値が小さくなり、より制限に適応できる
			}
			else if(bits[i]*2<=N) {
				if(ans+suji[i]<=K) {
					ans+=suji[i];
				}
			}
		}
		long output=0;

		for(int i=0; i<N; i++) {
			output+=(ans^uketori[i]);
		}
		pl(output);
	}
	public static void calcbit(long tmp) {
		long a=tmp;
		int counter=0;
		while(a>0) {
			if(a%2==1) {
				bits[counter]++;
			}
			counter++;
			a/=2;
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 52016
#include<bits/stdc++.h>
using namespace std;
using li = long long int;

int N;
int A[100010];
li Mountain[100010];
li total_vol = 0;     //the total vol of rain
li total_vol_o = 0;  //odd number's total vol

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){ cin >> A[i]; total_vol += A[i]; }
    for(int i = 0; i <= N/2; i++) total_vol_o += A[2 * i + 1];

    Mountain[1] = 2 * total_vol_o - total_vol;

    li neighbour = Mountain[1] / 2;
    cout << Mountain[1] << endl;
    for(int i = 1; i <= N-1; i++){
        Mountain[i+1] = 2 * (A[i] - neighbour);
        cout << Mountain[i+1] << endl;
        neighbour = Mountain[i+1] / 2;
    }
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	int n, m;
	cin >>n >>m;
	VL a(n), sm(n+1);
	rep(i, n) cin >>a[i];
	
	rep(i, n) (sm[i+1] = sm[i] + a[i] )%=m;
	map<ll, ll> mp;
	rep(i, n+1) mp[sm[i]]++;
	ll ans = 0;
	for(auto x: mp) if(x.second > 1){
		ans += (x.second *(x.second-1)) /2;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;double d,x;
    cin>>n>>d>>x;
    double ans=0;
    for(;n;--n)
    {
        ans+=d+(n-0.5)*x;
        d=((2*n+2)*d+5*x)/(2*n);
        x=(2*n+4)*x/(2*n);
    }
    printf("%.9f\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int n,k;
  scanf("%d%d",&n,&k);
  int d[k],a[k][n],c[n];
  for(int i=0;i<n;i++){
	c[i]=0;
  }
  for(int i=0;i<k;i++){
    	scanf("%d",&d[i]);
    for(int j=0;j<d[i];j++){
		scanf("%d",&a[i][j]);
      c[a[i][j]-1]++;
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
	if(c[i]==0)count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, A[20], B[20], C[20], ANS = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i], A[i]--;
	for (int i = 0; i < N; i++) cin >> B[i], ANS += B[i];
	for (int i = 0; i < N - 1; i++) cin >> C[i];
	for (int i = 0; i < N - 1; i++) {
		if (A[i] + 1 == A[i + 1]) ANS += C[A[i]];
	}
	cout << ANS << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int c;
  
  if (b < 10) c = a*10+b;
  else if(b < 100) c =a*100+b;
  else c = a*1000+b;
  
  double d = sqrt(c);
  if (d - int(d) == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  
}

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

char field[12][12];
const int direction_x[4] = {0, 0, 1, -1};
const int direction_y[4] = {-1, 1, 0, 0};
int new_x, new_y = 0;

void dfs(int x, int y){
	field[x][y] = '0';
	
	for(int i = 0;i < 4;i++){
		new_x = x+direction_x[i];
		new_y = y+direction_y[i];
		
		if(0 <= new_x && new_x < 12 && 0 <= new_y && new_y < 12){
			if(field[new_x][new_y] == '1'){
				dfs(new_x, new_y);
			}
		}
	}
	
	return ;
}

int main(){
	int result = 0;
    
	while(cin >> field[0]){
		result = 0;
		
		for(int j = 1;j < 12;j++){
			for(int k = 0;k < 12;k++){
				cin >> field[j][k];
				if (field[j][k] == EOF) { return 0; }
			}
		}
		
		for(int j = 0;j < 12;j++){
			for(int k = 0;k < 12;k++){
				if(field[j][k] == '1'){
					dfs(j,k);
					result++;
				}
			}
		}
		
		cout << result << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int N = 1e6 + 4;
vector <int> factors(N);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    for (int i = 1; i < N; ++i) {
        for (int j = i; j < N; j += i) {
            factors[j]++;
        }
    }

    int n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n-1; ++i) {
        int val = n - i;
        assert(0 <= val and val < N);
        // watch(val, factors[val]);
        ans += (factors[val]);
    }
    cout << ans;

    return 0;
}



Measured memory_bytes: 7028
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define swap(a,b) a^=b^=a^=b //二変数を入れ替え//
#define inf 1000000007

void sort(int x[], int left, int right);
int main(void);

//小さい順にソート//
void sort(int x[], int left, int right) {
	int temp[inf], smid, si, sj, sk;
	if (left >= right) return;
	if (left == right - 1) {
		if (x[left] > x[right]) {
			swap (x[left], x[right]);
		}
	return;
	}
	smid = (left + right) / 2;
	sort(x, left, smid);
	sort(x, smid+1, right);
	for (si = left; si <= smid; si++) temp[si] = x[si];
	for (si = smid+1 ; si <= right; si++) temp[si] = x[smid + right + 1 - si];
	si = left;
	sj = right;
	for (sk = left; sk <= right; sk++) {
		if (temp[si] <= temp[sj]) {
			x[sk] = temp[si];
			si=si+1;
		} else {
			x[sk] = temp[sj];
			sj=sj-1;
		}
	}
}

int main(void) {
	// your code goes here
  int n,a[3][101],i,j,sum,summax=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[1][i]);
  }
  for(i=1;i<=n;i++){
    scanf("%d",&a[2][i]);
  }
  for(i=1;i<=n;i++){
    sum=0;
    for(j=1;j<=i;j++){
      sum=sum+a[1][j];
    }
    for(j=i;j<=n;j++){
      sum=sum+a[2][j];
  }
    if(sum>summax) summax=sum;
  }
  printf("%d\n",summax);
	return 0;
}



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

int main() {
  int n, k; cin >> n >> k;
  vector<int> l(n);

  for (int& e: l) cin >> e;
  sort(l.rbegin(), l.rend());

  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += l.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256