akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n, i++)
using namespace std;

struct card{char suit, value; };

void bubblesort(struct card a[],int n){
  for(int i = 0; i < n; i++){
    for(int j = n-1; j > i; j--){
      if(a[j].value < a[j-1].value){
        card v = a[j];
        a[j] = a[j-1];
        a[j-1] = v;
      }
    }
  }
}

void selectionsort(struct card a[],int n){
  for(int i = 0; i < n;i++){
    int minj = i;
    for(int j = i; j < n; j++){
      if(a[j].value < a[minj].value){
        minj = j;
      }
    }
    card v = a[i];
    a[i] = a[minj];
    a[minj] = v;
  }
}

int main(void){
  int n; cin >> n;
  card a[n];
  card b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i].suit >> a[i].value;
    b[i] = a[i];
  }
  bubblesort(a,n);
  for(int i = 0; i < n; i++){
    if(i == n-1) cout << a[i].suit << a[i].value << endl;
    else cout << a[i].suit << a[i].value << " ";
  }
  cout << "Stable" << endl;
  selectionsort(b,n);
  int judge = 1;
  for(int i = 0; i < n; i++){
    if(a[i].suit != b[i].suit || a[i].value != b[i].value) judge = 0;
    if(i == n-1) cout << b[i].suit << b[i].value << endl;
    else cout << b[i].suit << b[i].value << " ";
  }
  if(judge) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    string S;
    cin >> S;
    cout << (S[0] != S[1] && S[1] != S[2] && S[2] != S[3] ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m; cin >> n >> m;
  vii islands(m);
  rep(i,m) {
    int a,b; cin >> a >> b;
    islands[i] = ii(a,b);
  }
  sort(islands.begin(), islands.end(), [](ii a, ii b) {return a.second < b.second;});
  int maxR = 0;
  int ans = 0;
  rep(i,m) {
    if (islands[i].first < maxR) continue;
    ans++;
    maxR = islands[i].second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

double dp[301][301][301];
ll o[301][301][301];
ld n;

ld pro(ll k, ll j, ll i)
{
	if(i+j+k == 0)
		return 0;
	dp[k][j][i] = n/(i+j+k);
	if(k > 0)
	{
		if(o[k-1][j][i] == 0)
			dp[k][j][i] += pro(k-1,j,i)*((ld)k/(ld)(i+j+k));
		else
			dp[k][j][i] += dp[k-1][j][i]*((ld)k/(ld)(i+j+k));
		o[k-1][j][i] = 1;
	}
	if(j > 0)
	{
		if(o[k+1][j-1][i] == 0)
			dp[k][j][i] += pro(k+1,j-1,i)*((ld)j/(ld)(i+j+k));
		else
			dp[k][j][i] += dp[k+1][j-1][i]*((ld)j/(ld)(i+j+k));
//		dp[k][j][i] += pro(k+1,j-1,i)*((ld)j/(ld)(i+j+k));
		o[k+1][j-1][i] = 1;
	}
	if(i > 0)
	{
		if(o[k][j+1][i-1] == 0)
			dp[k][j][i] += pro(k,j+1,i-1)*((ld)i/(ld)(i+j+k));
		else
			dp[k][j][i] += dp[k][j+1][i-1]*((ld)i/(ld)(i+j+k));
//		dp[k][j][i] += pro(k,j+1,i-1)*((ld)i/(ld)(i+j+k));
		o[k][j+1][i-1] = 1;
	}
//	trace4(k,j,i,dp[k][j][i]);
	return dp[k][j][i];
}

int main()
{
	FAST;
	ll i, j, k; 
	ld c1 = 0, c2 = 0, c3 = 0;
	cin >> n;
	ld a[(ll)n];
	fr(i,0,(ll)n)
	{
		cin >> a[i];
		if(a[i] == 1)
			c1++;
		else if(a[i] == 2)
			c2++;
		else if(a[i] == 3)
			c3++;
	}
	pro((ll)c1,(ll)c2,(ll)c3);
//	fr(i,0,c3+1)
//		fr(j,0,n+1-c1)
//			fr(k,0,n+1)
//			{
//				if(i + j + k == 0)	
//					continue;
//				if(i + j + k > n)
//					continue;
//				dp[k][j][i] = n/(i+j+k);
//				if(k > 0)
//					dp[k][j][i] += dp[k-1][j][i]*((ld)k/(ld)(i+j+k));
//				if(j > 0)
//					dp[k][j][i] += dp[k+1][j-1][i]*((ld)j/(ld)(i+j+k));
//				if(i > 0)
//					dp[k][j][i] += dp[k][j+1][i-1]*((ld)i/(ld)(i+j+k));
//				trace4(k,j,i,dp[k][j][i]);	  
//			}
	std::cout << std::fixed << std::setprecision(14) << dp[(ll)c1][(ll)c2][(ll)c3];	
}


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

int n, m, k, ans[111][111];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	int i = 1, j = 1;
	for (int c = 1; c <= k; ++c) {
		int sum = 0;
		scanf("%d", &sum);
		for (; sum; --sum) {
			ans[i][j] = c;
			if (i % 2 == 1) {
				if (j < m) {
					++j;
				} else {
					++i;
				}
			} else {
				if (j > 1) {
					--j;
				} else {
					++i;
				}
			}
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			printf("%d%s", ans[i][j], j == m ? "\n" : " ");
		}
	}
}

Measured memory_bytes: 384
import fractions

n,x=map(int,input().split())
z=[]
y=[]
z=list(map(int, input().split()))

for i in range(n):
  y.append(abs(x-z[i]))

if n==1:
  print(y[0])
else:
  gcm=y[0]
  for i in range(n):
    gcm=fractions.gcd(gcm,y[i])
  print(gcm)


Measured memory_bytes: 16300
#include<stdio.h>
#include<stdlib.h>

#define MAX 2000001
#define VMAX 10000

//?¨???°?????????
int main(){
  unsigned short *A,*B;

  int C[VMAX+ 1];
  int n,i,j;
  
  scanf("%d",&n);

  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);  

  for(i=0;i<=VMAX;i++)C[i] = 0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i] = C[i] + C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }printf("\n");

  return 0; 
}

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

typedef long long ll;
typedef vector<ll> vll;

vector<ll> n_layers(51), n_buns(51);

ll sub(int N, ll X) {
    if (N == 0) { return X; }
    ll w = n_layers[N-1];
    if (X <= 1) return 0;
    X -= 1;
    if (X <= w) return sub(N-1, X);
    X -= w;
    if (X <= 1) return n_buns[N-1] + X;
    X -= 1;
    if (X <= w) return n_buns[N-1] + 1 + sub(N-1, X);
    X -= w;
    return n_buns[N];
}

//ll solve(int N, ll X) {
//    return sub(N, X);
//}

int main() {
    n_layers[0] = n_buns[0] = 1;
    for (int i=1; i<=50; i++) {
        n_layers[i] = n_layers[i-1]*2 + 3;
        n_buns[i] = n_buns[i-1]*2 + 1;
    }


    int N; ll X;
    cin >> N >> X;
    cout << sub(N,X) << endl;
    return 0;
}


Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second

#define ALL(V)  V.begin(),V.end()

#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i;
    cin>>N;

    vlli V(N);
    rep(i,0,N)
    {
        cin>>V[i];
    }

    sort(V.begin(),V.end());

    reverse(V.begin(),V.end());

    lli j;

    vlli dp(N);
    rep(i,0,N)
    {
        dp[i]=1;
    }

    rep(i,0,N)
    {
        rep(j,0,i)
        {
            if(V[i]<V[j])
            {
                dp[i] = max(dp[i],dp[j]+1);
            }
        }
    }

    cout<<*max_element(dp.begin(),dp.end());






 return 0;
}


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

int N;

int encode(int a, int b) {
	if(a > b) swap(a, b);
	return a * N + b;
}

int seen[1000000], dep[1000000];

int dfs(const vector<vector<int>> &edge, int now) {
	if(seen[now] == 2) return dep[now];
	seen[now] = 1;
	for(auto &e : edge[now]) {
		if(seen[e] == 1) {
			cout << -1 << endl;
			exit(0);
		}
		dep[now] = max(dep[now], dfs(edge, e) + 1);
	}
	seen[now] = 2;
	return dep[now];
}

int main() {
	cin >> N;
	vector<vector<int>> edge(N*N);
	for(int i=0;i<N;i++) {
		int now = 0;
		for(int j=0;j<N-1;j++) {
			int a;
			cin >> a;
			a--;
			int next = encode(i,a);
			edge[now].push_back(next);
			now = next;
		}
	}
	cout << dfs(edge, 0) << endl;
}

Measured memory_bytes: 47232
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll ans = 0;
    if(n%2){
        ans = 1 + b[n/2] - a[n/2];
    }
    else{
        ans = 1 + (double)((b[n/2]+b[(n-1)/2])/2.0 - (a[n/2] + a[(n-1)/2])/2.0)*2.0;
    }
    cout << ans << endl;

    

}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    vector<ll> b(N,0);
    vector<ll> c(N,0);
    for(ll i=0;i<N;++i)cin>>a[i]>>b[i]>>c[i];
    vector<ll> dpa(N,0);
    vector<ll> dpb(N,0);
    vector<ll> dpc(N,0);
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    for(ll i=1;i<N;++i){
        dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
        dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
        dpc[i]=max(dpb[i-1]+c[i],dpa[i-1]+c[i]);
    }
    prt(max({dpa[N-1],dpb[N-1],dpc[N-1]}))

    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string b;
	cin >> b;
	if(b=="A")
	cout << "T";
	if(b=="C")
	cout << "G";
	if(b=="G")
	cout << "C";
 	if(b=="T")
	cout << "A";
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)

int main(){
	int x, r;
	scanf("%d", &x);
	
	r = 8;
	r = r - (x-400)/200;
	printf("%d\n", r);
	
	return 0;
}


Measured memory_bytes: 1732
/*
 * 树的遍历
 * 
 */
 
import java.util.Scanner;
public class Main {
	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static Node[] nodes;
	public static StringBuilder ans;
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int V = sc.nextInt();
		nodes = new Node[V];
		int[] in_num = new int[V];

		for(int i = 0; i < V; i++){
			in_num[i] = 0;
		}

		int node_id,left_child,right_child;

		for(int loop = 0; loop < V; loop++){

			node_id = sc.nextInt();
			left_child = sc.nextInt();
			right_child = sc.nextInt();

			nodes[node_id] = new Node(left_child,right_child);

			if(left_child != -1){
				in_num[left_child]++;
			}
			if(right_child != -1){
				in_num[right_child]++;
			}
		}

		int root = -1;
		for(int i = 0; i < V; i++){
			if(in_num[i] == 0){
				root = i;
				break;
			}
		}

		ans = new StringBuilder();

		ans.append("Preorder\n");
		Preorder(root);
		ans.append("\nInorder\n");
		Inorder(root);
		ans.append("\nPostorder\n");
		Postorder(root);
		ans.append("\n");

		System.out.print(ans.toString());	
	}
	
	
	public static void Preorder(int node_id){

		ans.append(" ").append(Integer.toString(node_id));

		if(nodes[node_id].left_child != -1){
			Preorder(nodes[node_id].left_child);
		}
		if(nodes[node_id].right_child != -1){
			Preorder(nodes[node_id].right_child);
		}
	}

	public static void Inorder(int node_id){

		if(nodes[node_id].left_child != -1){
			Inorder(nodes[node_id].left_child);
		}
		ans.append(" ").append(Integer.toString(node_id));

		if(nodes[node_id].right_child != -1){
			Inorder(nodes[node_id].right_child);
		}
	}

	public static void Postorder(int node_id){

		if(nodes[node_id].left_child != -1){
			Postorder(nodes[node_id].left_child);
		}
		if(nodes[node_id].right_child != -1){
			Postorder(nodes[node_id].right_child);
		}
		ans.append(" ").append(Integer.toString(node_id));
	}
}



class Node {
	public int left_child;
	public int right_child;
	
	Node(int arg_left_child,int arg_right_child)
	{
		left_child = arg_left_child;
		right_child = arg_right_child;
	}
}



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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//
   int dp[2005];
   ll dfs(ll sum, ll target) {
      if(dp[sum] != -1) return dp[sum];
      if(sum == target) return dp[sum] = 1;
      if(sum > target) return dp[sum] = 0;
      ll ans  = 0;
      for(ll i = 3; i <= target - sum; i++) {
         ans += dfs(sum + i, target);
         ans %= MOD;
      }
      return dp[sum] = ans;
   }
   void test_case() {
      ll n;
      cin >> n;
      memset(dp, -1, sizeof(dp));
      cout << dfs(0, n) << endl;
   }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin>>t;
    while(t-- >0){
      test_case();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 3660
now, angle, rad = [0,0], 0, 0
loop{
   line = gets.split(',').map(&:to_i)
   if line == [0,0]
	  break
   else
	  rad = Math::PI * angle / 180
	  now = [now[0] + line[0] * Math.sin(rad), now[1] + line[0] * Math.cos(rad)]
	  angle = angle + line[1]
   end
}
puts now[0].to_i
puts now[1].to_i

Measured memory_bytes: 6164
#include<iostream>
using namespace std;
int n,m;
int data[16][16];

int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
void reversal(int r,int c)
{
  int tmp=data[r][c];
  if(data[r][c]==0)
    data[r][c]=1;
  else
    data[r][c]=0;
  for(int i=0;i<4;i++)
    if(r+dx[i]>=0&&r+dx[i]<n &&
       c+dy[i]>=0&&c+dy[i]<n )
      if(tmp==data[r+dx[i]][c+dy[i]])
	reversal(r+dx[i],c+dy[i]);
}
void rotate(int r,int c,int s)
{
  int tmp[16][16];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      tmp[i][j]=data[i][j];


  for(int j=r;j<r+s;j++)
    for(int k=c;k<c+s;k++)
      {
	//		cout<<j<<" "<<k<<"<= ";
	//	cout<<r+s-1-(k-c)<<" "<<c+(j-r)<<endl;
	tmp[j][k]=data[r+s-1-(k-c)][c+(j-r)];
	//	tmp[j][k]=data[c+s-1-(k-c)][r+s-1-(j-r)];
	//tmp[k][j]=data[r+s-1-(j-r)][c+s-1-(k-c)];
      }

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      data[i][j]=tmp[i][j];
  
}
int main()
{
  cin>>n>>m;
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>data[i][j];
  for(int i=0;i<m;i++)
    {
      int o;
      cin>>o;
      if(o==0)
	{
	  int r,c,s,a;
	  cin>>r>>c>>s>>a;
	  r--;
	  c--;
	  for(int j=a/90;j>0;j--)
	    {
	      rotate(r,c,s);
	    }
	}
      else if(o==1)
	{//reversal
	  int r,c,s;
	  cin>>r>>c>>s;
	  r--;
	  c--;
	  for(int j=r;j<r+s;j++)
	    for(int k=c;k<c+s;k++)
	      {
	      if(data[j][k]==0)
		data[j][k]=1;
	      else
		data[j][k]=0;
	      }
	}
      else if(o==2)
	{//L_shift
	  int r;
	  cin>>r;
	  r--;
	  int tmp=data[r][0];
	  for(int i=0;i<n-1;i++)
	    data[r][i]=data[r][i+1];
	  data[r][n-1]=tmp;
	}
      else if(o==3)
	{//R_shift
	  int r;
	  cin>>r;
	  r--;
	  int tmp=data[r][n-1];
	  for(int i=n-1;i>0;i--)
	    data[r][i]=data[r][i-1];
	  data[r][0]=tmp;
	}
      else if(o==4)
	{
	  int r,c;
	  cin>>r>>c;
	  r--;c--;
	  reversal(r,c);
	}
      
    }
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      {
	cout<<data[i][j];
	if(j!=n-1)
	  cout<<" ";
	else
	  cout<<endl;
      }
}

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

const int N = 100000 ;
int size,
    c,
    l[N],
    r[N],
    b[2*N+1];
vector<int> vec[N];

void dfs(int v){
    l[v] = ++c;
    for(int i=0;i<vec[v].size();i++){
        dfs(vec[v][i]);
    }
    r[v] = ++c;
}

void add(int i,int x){
    while(i<=size){
        b[i] += x;
        i += i&-i;
    }
}

int getSum(int i){
    int ans = 0;
    while(i>0){
        ans += b[i];
        i -= i&-i;
    }
    return ans;
}

void queryChoose(int i){
    if(i == 0){
        int v,w;
        cin>>v>>w;
        add(l[v],w);
        add(r[v],-w);
    }else{
        int v;
        cin>>v;
        cout<<getSum(r[v] - 1)<<endl;
    }
}

int main(){
    int n;
    while(cin>>n){
        c = 0;
        size = 2*n + 1;
        for(int i=0;i<n;i++){
            int k;
            cin>>k;
            for(int j=0;j<k;j++){
                int child;
                cin>>child;
                vec[i].push_back(child);
            }
        }
        dfs(0);
        int q;
        cin>>q;
        for(int i=0;i<q;i++){
            int op;
            cin>>op;
            queryChoose(op);
        }
    }

    return 0;
}


Measured memory_bytes: 13236
#Educational DP Contest
#E-Knapsack2

#n = int(input())
N,W = map(int,input().split())
#lst1 = list(map(int,input().split()))

#dp table
#内側が価値v,外側がその品物をいれるかどうかのループを作る
#いきなりループに入れるように、内外共に0配列を余分に用意する
#価値vの総和はたかだか10*3*100=10**5なので、それだけ用意する
#なお、今回目指すのは価値の最大化ではなく、重さの最小化なので、infで初期化
dp = [[float("inf")]*(10**5+1) for _ in range(N+1)]
dp[0][0] = 0 #最小値を選んでいくため、0の初期化はここだけ

#process1
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(10**5+1):
        if j-v>=0: #入るなら
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v]+w)
        else:
            dp[i][j] = dp[i-1][j]


#output process
for i,j in enumerate(dp[-1]):
    if j <= W: #infの連続列の中に、たまにweightが紛れてる感じ
        ans = i
print(ans)

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

ll N, M, X;
vl C;
vector<vl> A;

ll min_cost = 1e9;

void dfs(int n, ll cost, vl U) {
    if (n == N) {
        bool achived = true;
        for (int i = 0; i < M; ++i) {
            if (U[i] < X) {
                achived = false;
                break;
            }
        }
        if (achived) min_cost = min(min_cost, cost);
    }
    else {
        dfs(n+1, cost, U);
        cost += C[n];
        for (int i = 0; i < M; ++i) {
            U[i] += A[n][i];
        }
        dfs(n+1, cost, U);
    }
}

int main() {
    cin >> N >> M >> X;
    ll c, a;
    for (int i = 0; i < N; i++) {
        cin >> c;
        C.push_back(c);
        vl Ar;
        for (int j = 0; j < M; ++j) {
            cin >> a;
            Ar.push_back(a);
        }
        A.push_back(Ar);
    }

    vl U;
    for (int i = 0; i < M; ++i) {
        U.push_back(0);
    }
    ll cost = 0;

    dfs(0, 0, U);

    if (min_cost == 1e9) {
        cout << -1 << endl;
    }
    else {
        cout << min_cost << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main() {
  int n;cin>>n;
  repd(a,1,3501){
    repd(b,a,3501){
      if(4*a*b-b*n-a*n <= 0)continue;
      if((a*b*n)%(4*a*b-b*n-a*n) == 0){
        cout << a << " " << b << " " << (a*b*n)/(4*a*b-b*n-a*n) << endl;
        return 0;
      }
    }
  }
}



Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var m, i, j, flag int
  fmt.Scan(&m)
  l:
  for i=1;i<=9;i++{
    for j=1;j<=9;j++{
      if i*j==m{
        flag=1
        break l
      }
    }
  }
  if flag==1{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
 long int n,q,s=0;
	cin>>n;
   long	int arr[n],a[100001]={0};
	for(int i=0;i<n;i++){
	cin>>arr[i];
	s=s+arr[i];
	a[arr[i]]++;
	  }
	cin>>q;
	int b[q],c[q];
	for(int i=0;i<q;i++)
	{
		cin>>b[i]>>c[i];
		int sum=a[b[i]];
		s=s+sum*(c[i]-b[i]);
		a[c[i]]=a[c[i]]+sum;
		a[b[i]]=0;
		cout<<s<<endl;	
	}	
}


Measured memory_bytes: 5968
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main() {
	fastio;
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	ll k = x+y;
	vector<ll> ra(a,0),ga(b,0),ca(c,0);
	vector<ll> pra(a+1,0),pga(b+1,0),pca(c+1,0);
	for(ll i=0;i<a;i++){
		cin>>ra[i];
		//pra[i+1] = pra[i] + ra[i];
		
	}
	for(ll i=0;i<b;i++){
		cin>>ga[i];
		//pga[i+1] = pga[i] + ga[i];
	}
	for(ll i=0;i<c;i++){
		cin>>ca[i];
		//pca[i+1] = pca[i] + ca[i];
	}
	sort(ra.begin(),ra.end());
	reverse(ra.begin(),ra.end());
	sort(ga.begin(),ga.end());
	reverse(ga.begin(),ga.end());
	sort(ca.begin(),ca.end());
	reverse(ca.begin(),ca.end());
	
	vector<ll> dp(x+y+1,0);
	ll r = 0, g = 0;
	
	while(r<x || g<y){
		if(r==x){
			dp[x+g+1] = dp[x+g] + ga[g];
			g++;
		}
		else if(g==y){
			dp[r+y+1] = dp[r+g] + ra[r];
			r++;
		}
		else{
			if(ra[r]>ga[g]){
				dp[r+g+1] = dp[r+g] + ra[r];
				r++;
			}
			else{
				dp[r+g+1] = dp[r+g] + ga[g];
				g++;
			}
		}
	}
	/*for(ll i=0;i<=a+b;i++){
		cout<<dp[i]<<" ";
	}
	cout<<"\n";*/
	
	for(ll i=0;i<c;i++){
		pca[i+1] = pca[i] + ca[i];
	}
	ll ans = 0;
	for(ll i=0;i<=c;i++){
		if(k>=i) ans = max(ans,pca[i] + dp[k-i]); 
	}
	cout<<ans<<"\n";
	
	
	
}

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

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m = 26;
	int d;
	cin >> d;

	vector<ll> c(m);
	rep(i, m) cin >> c[i];

	vector<vector<ll>> s(d, vector<ll>(m));
	rep(i, d) rep(j, m) cin >> s[i][j];

	vector<ll> pen(m, 0);
	ll sat = 0;

	vector<ll> t(d);
	rep(i, d) {
		cin >> t[i];
		t[i]--;
	}
	
	rep(i, d){
		rep(j, m) pen[j] += c[j];
		sat += s[i][t[i]];
		pen[t[i]] = 0;
		rep(j, m) sat -= pen[j];
		cout << sat << endl;
	}

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
unordered_map<int, int> mp;

int f(int i, int j,int x,int y)
{
		return min(j - i, abs(x - i) + 1 + abs(j - y));
}
int main() {
	int n, x, y;
	cin >> n >> x >> y;

	for (int i = 1;i <= n;i++) {
		for (int j = i + 1; j <= n;j++)
		{
			mp[f(i, j, x, y)]++;
		}
	}
	for (int i = 1;i < n;i++) {
		cout << mp[i] << endl;
}
}

Measured memory_bytes: 384
S = input()

pos_RL = []
prev = S[0]
for i in range(len(S)):
    cur = S[i]
    if prev + cur == 'RL':
        pos_RL.append(i-1)
    prev = cur
        
def countLR(start, end):
    if start == end:
        return (0, 0)        
    L = 0
    R = 0
    for i in range(start, end):
        if S[i] == 'L':
            L += 1
        else:
            R += 1
    return (L, R)

ans = [0] * len(S)
for i in range(len(pos_RL)+1):
    if i == 0:
        L, R = countLR(0, pos_RL[0])
    else:
        if i == len(pos_RL):
            L2, R2 = countLR(pos_RL[i-1]+2, len(S))
        else:
            L2, R2 = countLR(pos_RL[i-1]+2, pos_RL[i])
        if((R + L2) % 2 == 0):
            ans[pos_RL[i-1]] = (R + L2) // 2 + 1
            ans[pos_RL[i-1]+1] = (R + L2) // 2 + 1
        else:
            if L2 % 2 == 0:
                ans[pos_RL[i-1]] = (R + L2) // 2 + 1
                ans[pos_RL[i-1]+1] = (R + L2) // 2 + 2
            else:
                ans[pos_RL[i-1]+1] = (R + L2) // 2 + 1
                ans[pos_RL[i-1]] = (R + L2) // 2 + 2
        L, R = L2, R2


print(*ans)


Measured memory_bytes: 53340
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int N, K;

long long int B[2001][2001], W[2001][2001];

long long int diff[2001][2001];
long long int sum_diff[2001][2001];

int main(void) {

	cin >> N >> K;
	long long int tmp_x, tmp_y;
	string str;
	for (int i = 1; i <= N; i++) {
		cin >> tmp_x; 
		cin >> tmp_y; 
		cin >> str; if (str == "B") { B[tmp_x % (2 * K)][tmp_y % (2 * K)]++; }
		else { W[tmp_x % (2 * K)][tmp_y % (2 * K)]++; }
	}

	/*for (int i = 0; i <= 2 * K - 1; i++) {
		for (int j = 0; j <= 2 * K - 1; j++) {
			W[i][j] = W[i % (2 * K)][j % (2 * K)];
			B[i][j] = B[i % (2 * K)][j % (2 * K)];
		}
	}*/

	//====== diff ============================//
	for (int i = 0; i <= 2 * K - 1; i++) {
		for (int j = 0; j <= 2 * K - 1; j++) {
			diff[i][j] = B[i][j] - W[i][j];
		}
	}

	//=== sum_diff ===============================//
	
	for (int i = 0; i <= 2* K ; i++) {
		sum_diff[i][2 * K] = 0;
	}
	for (int j = 0; j <= 2 * K; j++) {
		sum_diff[2*K][j] = 0;
	}

	for (int i = 2 * K - 1; i >= 0; i--) {
		for (int j = 2 * K - 1; j >= 0; j--) {
			sum_diff[i][j] = diff[i][j] + sum_diff[i + 1][j] + sum_diff[i][j + 1] - sum_diff[i+1][j+1];
		}
	}

	//==========================================//

/*	for (int i = 0; i <= 2 * K; i++) {
		for (int j = 0; j <= 2 * K; j++) {
			cout << " " << sum_diff[i][j];
		}cout << endl;
	}
	*/
	//====== W ================================//
	long long int count_W = 0;
	for (int i = 0; i <= 2 * K - 1; i++) {
		for (int j = 0; j <= 2 * K - 1; j++) {
			count_W += W[i][j];
		}
	}
	//==========================================//

	long long int ans = 0;

	long long int count;

	for (int I = 0; I <= K-1; I++) {
		for (int J = 0; J <= 2*K-1; J++) {

			count = 0;

			if (J <= K) {
				count += sum_diff[0][0] - sum_diff[I][0] - sum_diff[0][J] + sum_diff[I][J];
				count += sum_diff[I + K][0] - sum_diff[I + K][J];
				count += sum_diff[0][J + K] - sum_diff[I][J + K];
				count += sum_diff[I][J] - sum_diff[I + K][J] - sum_diff[I][J + K] + sum_diff[I + K][J + K];
				count += sum_diff[I + K][J + K];
			}
			else {
				count += sum_diff[0][J - K] - sum_diff[I][J - K] - sum_diff[0][J] + sum_diff[I][J];
				count += sum_diff[I][0] - sum_diff[I + K][0] - sum_diff[I][J - K] + sum_diff[I + K][J - K];
				count += sum_diff[I][J] - sum_diff[I + K][J];
				count += sum_diff[I + K][J - K] - sum_diff[I + K][J];
			}

			count += count_W;

			ans = max(ans, count);
		}//J-loop fin
	}//I-loop

	cout << ans << endl;

//	system("pause");
	return 0;
}

Measured memory_bytes: 125312
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

t=1
# t=int(input())
for _ in range(t):
    n=L()[0]
    a,b,c,d=0,0,0,0
    for i in range(n):
        x=input()
        if x=="AC":
            a+=1
        elif x=="WA":
            b+=1
        elif x=="TLE":
            c+=1
        else:
            d+=1
    print("AC x ",a)
    print("WA x ",b)
    print("TLE x ",c)
    print("RE x ",d)
    



Measured memory_bytes: 10656
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 200005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int n;
ll k;
ll a[55][55];
ll b[55][55];
ll c[55][55];

void copy(ll a[][55], ll b[][55]) {
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            a[i][j] = b[i][j];
}

void mul(ll a[][55], ll b[][55], ll c[][55]) {
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            a[i][j] = 0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int p=1;p<=n;p++)
                a[i][j] = (a[i][j] + b[i][p] * c[p][j] % mod) % mod;
}

void calc(ll k) {
    if (k == 1) {
        copy(b, a);
        return;
    }
    calc(k / 2);
    mul(c, b, b);
    if (k & 1)
        mul(b, c, a);
    else 
        copy(b, c);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> n >> k;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin >> a[i][j];

    calc(k);
    ll ans = 0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ans = (ans + b[i][j]) % mod;

    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
 
void solve(){
  ll l,r,ans=2019; cin >>l >>r;
  if(r-l>2017||l%2019>r%2019) cout <<0;
  else{
    for(ll i=l; i<r; i++) for(ll j=i+1; j<=r; j++){
      ans=min(ans,(i*j)%2019);
    }
  cout <<ans;
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define pb push_back

typedef long long ll;
using namespace std;
int MOD (1e9+7);
int powMod(int a, int n, int m){
  ll pro = 1, tmp = a;
  for(; n > 0; n >>= 1){
    if(n & 1) pro = (pro * tmp) % m;
    tmp = tmp * tmp % m;
  }
  if (pro < 0) cout << "pro < 0" << a << "," << n << endl;
  return pro;
}

vector<int> A, R;
int comb(int n, int c){
  return int(ll(A[n + c]) * R[n] % MOD * R[c] % MOD);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;

  ll t = 1;
  A.pb(1);
  R.pb(1);
  FOR(i, 1, N + M + K + 1){
    t = t * i % MOD;
    A.pb(t);
    R.pb(powMod(t, MOD - 2, MOD));
  }
  int sum = M + K, p3 = powMod(3, sum, MOD), ret = p3, r3 = powMod(3, MOD - 2, MOD);
  if(M > K) swap(M, K);
  ll pre = 1;

  FOR(i, 1, sum + 1){
    pre *= 2;
    p3 = ll(p3) * r3 % MOD;
    if(i > M){
      pre = pre + MOD - comb(M, i - M - 1);
      if(i > K) pre = pre + MOD - comb(K, i - K - 1);
    }
    pre %= MOD;
    ret += pre * comb(N - 1, i) % MOD * p3 % MOD;
    ret %= MOD;
  }
  cout << ret << endl;
}


Measured memory_bytes: 7516
n, m = map(int, input().split())
road = [0] * n

for i in range(0, m):
    a, b = map(int, input().split())
    road[a-1] = road[a-1] + 1
    road[b-1] = road[b-1] + 1

for i in road:
    print(i)

Measured memory_bytes: 3064
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;


int main(void){
    ll n;
    ll limit=0;
    vector <ll> input;
    cin >> n;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        input.push_back(tmp);
        CHMAX(limit, tmp);
    }

    bool dp[1000010];
    REP(i, 1000010){
        dp[i] = true;
    }

    sort(ALL(input));

    REP(i,n){
        if(i>0){
            if(input[i]==input[i-1]){
                dp[input[i]] = false;
                continue;
            }
        }
        ll value = input[i]*2;
        while(value < limit +1){
//            if(dp[value] == false){
//                break;
//            }
            dp[value] = false;
            value +=  input[i];
        }
    }

        ll ans=0;
        REP(i,input.size()){
            if(dp[input[i]]){
                //cout << input[i] << endl;
                ans++;
            }
        }
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {

            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();

        }
    }
}


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

using namespace std;

int a, b, c, k;
int sum;

int main(void)
{
	scanf("%d %d %d %d", &a, &b, &c, &k);
	
	if(a >= k)
		printf("%d", k);
	
	else
	{
		k -= a;
		
		if(b >= k)
			printf("%d", a);
		
		else
		{
			k -= b;
			
			if(c >= k)
				printf("%d", a - k);
		}
	}
	
	return 0;
}

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

using namespace std;
const int N=2e5+10;

const int MAX=1e9+10;
vector <int> g[N];
int vis[N];
int ans;
typedef long long ll;
int a[N];
map<int,int>mp;
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   ll ans=0;
   for(int i=1;i<=n;i++){
        ans+=mp[i-a[i]];
        mp[a[i]+i]++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 25996
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,K;
    cin >> N >> K;
    vector<int> H(N); for(int i = 0; i < N; ++i) cin >> H[i];
    sort(H.begin(), H.end());
    int ret = 1e9;
    for(int i = 0; i + K - 1 < N; ++i){
        ret = min(ret, H[i+K-1] - H[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
int *buildFail(const string &p) {
  int m = p.size();
  int *fail = new int[m+1];
  int j = fail[0] = -1;
  for (int i = 1; i <= m; ++i) {
    while (j >= 0 && p[j] != p[i-1]) j = fail[j];
    fail[i] = ++j;
  }
  return fail;
}

vector<set<int>> e;
int num[500010];
int rec(int c){
	if(num[c] < 0){
		cout << -1 << endl;
		exit(0);
	}
	if(num[c]) return num[c];
	if(!e[c].size()) return num[c] = 0;
	
	num[c] = -1;
	return num[c] = rec(*e[c].begin()) + 1;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size();
	int *fail = buildFail(t);
	e.resize(n);
  for (int i = 0, k = 0; i < n + m; ++i) {
    while (k >= 0 && t[k] != s[i % n]) k = fail[k];
    if (++k >= m) {
    	e[(i - m % n + n + 1) % n].insert((i + 1) % n);
      k = fail[k];
    }
  }
	//dbg(e);
	int ans = 0;
	rep(i, n) if(!num[i]) ans = max(ans, rec(i));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 59804
Nmax = int(input())
ans = 1
maxnum = 0
for N in range(1, Nmax+1):
    cnt=0
    N_before = N
    while 1:
        if int(N/2) == int((N+1)/2):
            N = N/2
            cnt +=1
        else:
            break
    if cnt > maxnum:
        maxnum = cnt
        ans = N_before
print (ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " = " << (x) << endl
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	char x;
	cin >> x;
	if(x >= 'A' && x <= 'Z')
		cout << 'A';
	else
		cout << 'a';
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	int n;
	cin>>n;
	int count=0,a=1,b=1;
	while(a*b<n){
		while(a*b<n){
			count++;
			b++;
		}
		b=1;
		a++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3672
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[100000],d,m,n,p=0;
  int sm=0;
  cin>>n>>m;
  a[0]=0;
  for(i=1;i<n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
  }
  for(i=0;i<m;i++){
    cin>>d;
    sm=(sm+a[d>0?p+d:p]-a[d<0?p+d:p])%100000;
    p+=d;
  }
  cout<<sm<<endl;
  return 0;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll H, W;
    cin >> H >> W;
    ll a[H][W];
    REP(i, 0, H) {
        REP(j, 0, W) {
            cin >> a[i][j];
        }
    }
    vector<plglg> ans;
    REP(i, 0, H) {
        REP(j, 0, W - 1) {
            if (a[i][j] % 2 == 1) {
                ans.push_back(plglg(i, j));
                a[i][j]--;
                a[i][j + 1]++;
            }
        }
    }
    REP(i, 0, H - 1) {
        if (a[i][W - 1] % 2 == 1) {
            ans.push_back(plglg(i, W - 1));
            a[i][W - 1]--;
            a[i + 1][W - 1]++;
        }
    }
    cout << ans.size() << endl;
    REP(i, 0, ans.size()) {
        ll h = ans[i].first + 1;
        ll w = ans[i].second + 1;
        if (w == W) {
            cout << h << " " << w << " " << h + 1 << " " << w << endl;
        } else {
            cout << h << " " << w << " " << h << " " << w + 1 << endl;
        }
    }
}


Measured memory_bytes: 6128
// dfs(recursive)

package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func push(sta []pair, x pair) []pair { return append(sta, x) }

func fill(a []int, val int) {
	for i := 0; i < len(a); i++ {
		a[i] = val
	}
	return
}

type pair struct {
	u, w int
}

var al [][]pair
var ans []int

func dfs(now, c int) {
	ans[now] = c
	for _, e := range al[now] {
		if ans[e.u] != -1 {
			continue
		}
		if e.w%2 == 0 {
			dfs(e.u, c)
		} else {
			dfs(e.u, 1-c)
		}
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	al = make([][]pair, n)
	for i := 0; i < n-1; i++ {
		ru, rv, rw := ri()-1, ri()-1, ri()
		al[ru] = push(al[ru], pair{u: rv, w: rw})
		al[rv] = push(al[rv], pair{u: ru, w: rw})
	}
	ans = make([]int, n)
	fill(ans, -1)
	dfs(0, 0)
	for _, a := range ans {
		fmt.Println(a)
	}
}


Measured memory_bytes: 21120