akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  if((a+b)%2==0){
    co((a+b)/2)
  }
  else{
    co("IMPOSSIBLE")
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>

int main(){
    std::string s;
    int n;

    std::cin >> s >> n;

    for (int i = 0; i < n; i++) {
        std::string op;
        int a, b;
        std::cin >> op >> a >> b;

        if (op == "print") {
            std::cout << s.substr(a, b - a + 1) << std::endl;
        } else if (op == "reverse") {
            for (int j = a; j < (b - a + 1) / 2 + a; j++) {
                std::swap(s[j], s[b - (j - a)]);
            }
        } else {
            std::string p;
            std::cin >> p;
            for (int j = a; j <= b; j++) {
                s[j] = p[j - a];
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

string ans;
char c[5];
int a,l;

int main()
{
  l=0;
  while(cin>>c[l++]){}
  rep(i,(1<<3)){
    ans = "";
    a = 0;
    rep(j,4){
      if(j==0){
        ans += c[j];
        a += (c[j]-'0');
      }else if(i&(1<<(j-1))){
        ans += "+";
        ans += c[j];
        a += (c[j]-'0');
      }else{
        ans += "-";
        ans += c[j];
        a -= (c[j]-'0');
      }
    }
    if(a==7){
      ans += "=7\n";
      break;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, p; string w; cin >> N >> w;
  map<string, int> m; m[w] = 1; while (p = w.back(), cin >> w) if (m[w]++ or w[0] != p) puts("No"), exit(0);
  puts("Yes");}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int a,b,c;
    rd(c,b,a);
    int k;rd(k);
    while(b<=c and k>0){
        b*=2;k--;
    }  
    while(a<=b and k>0){
        a*=2;k--;
    } 
    if(a>b and b>c)cout<<"Yes\n";
    else cout<<"No\n";
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3652
N, K = map(int,input().split())
X = list(map(int,input().split()))
fu = 0
sei = 0
for i in range(N):
    if X[i] < 0:
        fu += 1
    else:
        sei += 1
#X[0]からX[fu-1]までは負なのだよ(ただしfu >= 1)
#このときX[fu]からX[N-1]までは0以上なのだよ
#X[-1] >= 0ならfu+1通りのシミュレーションをすればいいのだよ

if fu == 0:
    print(str(X[K-1]))
else:
    kouho = []
    for i in range(fu):
        # fu-i個の負数をさらうよ(K-(fu-i)個の0以上の数をさらうよ) X[fu]で1個, X[fu + K-(fu-i) - 1]でK-(fu-i)個
        # fu-i+sei >= Kじゃないとだめだよ
        if(fu-i+sei < K):
            break
        else:
            kouho.append(min(2*abs(X[i])+abs(X[fu + K-(fu-i) - 1]), abs(X[i])+abs(2*X[fu + K-(fu-i) - 1])))
    if sei >= K:
        kouho.append(X[fu+K-1])
    if fu >= K:
        kouho.append(abs(X[fu-K]))
    print(str(min(kouho)))

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string S, T;
    cin >> S >> T;
    T += S;
    cout << T << endl;

    return 0;
}



Measured memory_bytes: 256
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=1000100,p=998244353;
int n,cas,num;
int a[110],ans[110];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--)
	{
		int k=0;
		for (int j=1;j<=i;j++)
			if (a[j]==j) k=j;
		if (k==0)
		{
			puts("-1");
			return 0;
		}
		ans[i]=k;
		for (int j=k;j<i;j++) a[j]=a[j+1];
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;


int main()
{
	while(true) {
		int h;
		int w;
		cin >> h >> w;
		if (h == 0 && w == 0)break;

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

long double EPS = 1E-9;

bool sgn(double a, double b) {
    return a < b - EPS;
}


int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    bool flag = 4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0;
    // if (c - a - b < 0) flag = false;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int A,B= 0;


int main(){

	cin >> A >> B;

	string SA;
	int cnt = 0;

	for (int i = A; i < B + 1; ++i) {
		SA = to_string(i);
		if (SA.at(0) == SA.at(4) && SA.at(1) == SA.at(3)) {
			cnt = cnt + 1;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
 ll n;
 cin>>n;
 ll a[n];
 for(ll i=0;i<n;i++){
  cin>>a[i];
 }
 sort(a,a+n,greater<>());
 ll times=n-1;
 times-=1;
 ll ans=0;
 for(ll i=1;i<=n;i++){
  if(times>1){
   ans+=(2*a[i]);
   times-=2;
  }
  else if(times==1){
   ans+=a[i];
   break;
  }
  else
   break;
 }
 cout<<ans+a[0]<<"\n";
}





Measured memory_bytes: 5196
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var ans = n * 800 - (n / 15) * 200;
            WriteLine(ans);
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
a=list(map(int,input().split()))

if(a[2]%a[1]>=1):
  ans_a=int(a[2]/a[1])+1
else:
  ans_a=int(a[2]/a[1])
if(a[0]%a[3]>=1):
  ans_b=int(a[0]/a[3])+1
else:
  ans_b=int(a[0]/a[3])
if(ans_a <=ans_b):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 61728
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = Integer.parseInt(br.readLine());
        int[] sides = new int[n];
        StringTokenizer st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; ++i) sides[i] = Integer.parseInt(st.nextToken());
        Arrays.sort(sides);
        int total = 0;
        for (int i = 0; i < sides.length; ++i) {
            for (int j = i + 1; j < sides.length; ++j) {
                for (int k = j + 1; k < sides.length; ++k) {
                    if (sides[i] + sides[j] > sides[k] && sides[i] != sides[j] && sides[j] != sides[k] && sides[i] != sides[k]) {
                        ++total;
                    }
                }
            }
        }
        pw.println(total);
        pw.close();
    }
}

Measured memory_bytes: 26444
def main():
    N = int(input())

    *A, = (int(x) - 1 for x in input().split())
    B = map(int, input().split())
    *C, = map(int, input().split())

    ans = sum(B)
    for a, b in zip(A, A[1:]):
        if b - a == 1:
            ans += C[a]
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    ll n;
    cin >> n;

    ll a[n];
    map<ll, ll> m;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        auto itr = m.find(a[i]);
        if(itr == m.end()){
            m.insert(make_pair(a[i], 1));
        }else{
            m[a[i]]++;
        }
    }

    map<ll, ll> an;
    ll go = 0;

    for(auto i = m.begin(); i != m.end(); ++i){
        ll k = i->first;
        ll l = i->second;
        ll q = (l * (l - 1)) / 2;
        go += q;
        an.insert(make_pair(k, q));
    }

    for(ll i = 0; i < n; i++){
        ll k = m[a[i]];
        ll ans = go;
        ans -= (k * (k - 1)) / 2;
        k--;
        if(k >= 2){
            cout << ans + (k * (k - 1)) / 2 << endl;
        }else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n,t;
  cin >> n >> t;
  ll ans=0;
  ll now=0;
  rep(i,n){
    ll ti;
    cin >> ti;
    if(now+t>ti){
      ans+=ti-now;
      now=ti;
    }
    else if(now>ti){
      now=ti;
    }
    else{
      ans+=t;
      now=ti;
    }
  }
  cout << ans+t<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int c,n,m,s,e,min,a,b,co,mi,i,j,k;
  while(scanf("%d %d %d %d %d",&c,&n,&m,&s,&e),c||n||m||s||e){
    s--;
    e--;
    int d[100][100]={0};
    int p[11][100]={0};
    while(m--){
      scanf("%d %d %d",&a,&b,&co);
      a--;
      b--;
      d[a][b]=d[b][a]=co;
    }
    for(i=0;i<=c;i++){
      mi=s;
      int f[100]={0};
      for(j=0;j<n;j++){
	f[mi]=1;
	for(k=0;k<n;k++){
	  if(d[mi][k]==0||f[k])continue;
	  if(p[i  ][k]==0||p[i  ][k]>p[i][mi]+d[mi][k]){
	    p[i  ][k]=p[i][mi]+d[mi][k];
	  }
	  if(p[i+1][k]==0||p[i+1][k]>p[i][mi]+d[mi][k]/2){
	    p[i+1][k]=p[i][mi]+d[mi][k]/2;
	  }
	}
	min=210000000;
	for(k=0;k<n;k++){
	  if(p[i][k]==0||f[k])continue;
	  if(min>p[i][k]){
	    min=p[i][k];
	    mi=k;
	  }
	}
      }
      /*for(j=0;j<=c;j++){
	for(k=0;k<n;k++)printf("%d\t",p[j][k]);printf("\n");
	}printf("\n");//*/
    }
    min=210000000;
    for(i=0;i<=c;i++){
      if(p[i][e]==0)continue;
      if(min>p[i][e])min=p[i][e];
    }
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 652
#include <stdio.h>

int prime(int x)
{
    int i;
    for(i=2;i*i<=x;i++)
    {
        if(x%i==0) return 1;
    }
    return 0;
}

int main(void)
{
    int n,num,i,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        if(prime(num)==0) cnt++;
    }
    printf("%d\n",cnt);
    
    return 0;
}



Measured memory_bytes: 2036
s = list(input())
for i in range(2**3):
    f = (s[0])
    for j in range(3):
        if (i>>j)&1:
            f = f +"+"
        else:
            f = f + "-"
        f = f + s[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<ll> yakusu(ll x){
	vector<ll> res;
	for(ll i = 1; i*i <= x; i++){
		if(x%i == 0){
			res.push_back(i);
			if(x/i != i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

ll f(ll n, ll k){
	if(n%k == 0)return n/k;
	return n%k;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    auto a = yakusu(n);
    auto b = yakusu(n-1);
    
    ll ans = b.size()-1;
    //print(ans)
    zep(i, 0, a.size()){
    	if(a[i] > 1){
    		ll tmp = n;
    		//cout << a[i] << endl;
    		while(tmp >= a[i]){
    			tmp = f(tmp, a[i]);
    		}
    		if(tmp == 1){
    			ans++;
    		}
    	}
    }
    
    print(ans)
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	int ret = 0;
	FOR(i, n) {
		int x;
		cin >> x;
		ret += 2*min(x, k-x);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()

if H == 1 or W == 1:
    print(1)
else:
    print(ceil(H * W / 2))


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

int main() {
  int n; cin>>n;
  string s; cin>>s;

  int sum=1;
  rep(i, n-1) {
    if (s[i]!=s[i+1]) sum++;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main()
{
	ll x;
	cin >> x;
	ll _500 = 0;
	ll _5 = 0;
	_500 = x / 500;
	x %= 500;
	_5 = x / 5;
	cout << _500 * 1000 + _5 * 5 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(), B = sc.nextLong(), K = sc.nextLong();
		long diff_A = Math.min(A, K);
		A -= diff_A;
		K -= diff_A;
		long diff_B = Math.min(B, K);
		B -= diff_B;
		K -= diff_B;
		System.out.println(A + " " + B);
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(std::string C){
	printf("%c\n", C[0]+1);
}

int main(){
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r,int m){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%m)*(p%m))%m;
	 }
	 r=r>>1;
     p=((p%m)*(p%m))%m;
	}
	return ans;
}
signed main() {
	garou;
	int n;
	cin>>n;
   int x=pow(10,n,mod);
   x=(x%mod-pow(9,n,mod)+mod)%mod;
   x=(x%mod-pow(9,n,mod)+mod)%mod;
   x=(x%mod+pow(8,n,mod))%mod;
   cout<<x%mod;
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 2123450
#else
#define SIZE 2123450
#endif

int N;
int A[SIZE], B[SIZE];

void solve() {
    cin>>N;
    REP1(i,N)cin>>A[i];
    vector<int> ans;
//    vector<int> B(N + 1, 0);
    RREP1(i, N) {
        int sum = 0;
        for (int j = i; j <= N; j += i) sum += B[j];
        
        if ((sum + A[i]) % 2 == 1) {
            B[i]=1;
            ans.push_back(i);
        } else {
            B[i]=0;
        }
    }
    cout << ans.size() << endl;
    for(auto x: ans) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
const int N=100001;
int main(){
int lps[N]={0,0}; bool notP[N]={true,true}, frag[N]={true,true};
for(int i=2; i*i<N; i++){
if(!frag[i]){
  notP[i]=false; frag[i]=true;
  for(int m=2*i; m<N; m+=i){ notP[m]=frag[m]=true; }
}  
}
for(int i=2; i<N; i++){ lps[i]=lps[i-1]; if(!notP[i]&&!notP[(i+1)/2]){ lps[i]++; } }
int Q, l, r; cin >> Q;
for(int i=0; i<Q; i++){ cin >> l >> r; cout << lps[r]-lps[l-1] << "\n"; } 
}

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

int main() {
  long int A,B,C,K;cin>>A>>B>>C>>K;
  if (A >= K) cout<<K<<endl;
  else if (B >= K-A) cout<<A<<endl;
  else {
    K = K-(A+B);
    cout<<A-K<<endl;}
}


Measured memory_bytes: 3628
#include<stdio.h>

void MergeSort(int*,int,int);
void Merge(int*,int,int,int);
#define INFTY 1000000000

int count=0;

int main(){
    int A[500000];
    int i,n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    MergeSort(A,0,n);
    for(i=0;i<n-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",count);
    return 0;
}
void Merge(int *A, int left, int mid, int right){
    int n1,n2;
    int L[250002],R[250002];
    int i,j,k;

    n1=mid-left;
    n2=right-mid;

    for(i=0;i<=n1-1;i++){
        L[i]=A[left+i];
    }
    for(i=0;i<=n2-1;i++){
        R[i]=A[mid+i];
    }
    L[n1]=INFTY;
    R[n2]=INFTY;
    i=0;
    j=0;
    for(k=left;k<right;k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
            count++;
        }
        else {
            A[k]=R[j];
            j++;
            count++;
        }
    }
}
void MergeSort(int *A, int left, int right){
    int mid;
    if (left+1 < right){
        mid = (left + right)/2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<string> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  string prev = v[0];
  set<string> st = {v[0]};
  for (int i = 1; i < N; i++) {
    if (v[i][0] == prev[prev.size() - 1] && st.find(v[i]) == st.end()) {
      prev = v[i];
      st.insert(v[i]);
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static int ans(double v){
	double t=v/9.8;
	double y=4.9*Math.pow(t,2);
	return (int)(y/5.0)+2;
    }
    public static void main(String[] args)throws IOException{
	BufferedReader br=
	    new BufferedReader(new InputStreamReader (System.in));
	String buf;

	while((buf=br.readLine())!=null){
	    System.out.println(ans(Double.parseDouble(buf)));
	}
    }
}

Measured memory_bytes: 9760
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;

    int s = (a + b + c) / 2;

    int ans = sqrt(s * (s - a) * (s - b) * (s - c));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	ll N,Q;
	cin >> N;
	ll sum = 0;
	vector<int> a(N);
	vector<ll> ans;
	map<int,int> m;
	rep(i,N){
		cin >> a[i];
		m[a[i]]++;
	}
	cin >> Q;
	for(auto x:m){
		sum += x.first*x.second;
	}
	rep(i,Q){
		int b,c;
		cin >> b >> c;
		ll cnt = m[b];
		sum -= b*cnt;
		m[b] = 0;
		m[c] += cnt;
		sum += c*cnt;
		ans.pb(sum);
	}
	rep(i,ans.size()){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8748
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        Point p1 = new Point();
        Point p2 = new Point();
 
        p1.setX(scanner.nextDouble());
        p1.setY(scanner.nextDouble());
        p2.setX(scanner.nextDouble());
        p2.setY(scanner.nextDouble());
 
        System.out.printf("%.10f\n", calcDistance(p1,p2));
    }
 
    public static double calcDistance(Point p1,Point p2){
        return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
    }
}
 
class Point{
 
    private double x;
    private double y;
 
    Point(){
        x = 0;
        y = 0;
    }
 
    public double getX() {
        return x;
    }
    public void setX(double x) {
        this.x = x;
    }
    public double getY() {
        return y;
    }
    public void setY(double y) {
        this.y = y;
    }
}


Measured memory_bytes: 28232
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
v(int) adj[200001];
int h[100001];
/*void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
    int n,m;
    cin>>n>>m;
    sa(h,n,d);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int c=0;
    rep(i,n){
        bool flag=true;
        rep(j,adj[i].size()){
            if(h[i]<=h[adj[i][j]])
                flag=false;
        }
        if(flag) c++;
    }
    cout<<c<<"\n";
  return 0;
}


Measured memory_bytes: 11608
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    a, b = im.inputMultiple()
    # Logic ############################################################################################################
    if a>=13:
        print(b)
    elif a >= 6:
        print(b // 2)
    else:
        print(0)
    # Output ###########################################################################################################

    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 23184
#include<stdio.h>
int main(){

  int m,f,r,i,sum;

  while(1){
    scanf("%d%d%d",&m,&f,&r);

    if(m == -1 && f == -1 && r == -1)break;
    if(m == -1){
      m=-50;
    }else if(f == -1){
      f=-50;
    }

    sum=m+f;
    if(80 <= sum){
      printf("A\n");
    }else if(65 <= sum && sum < 80){
      printf("B\n");
    }else if(50 <= sum && sum < 65){
      printf("C\n"); 
    }else if(30 <= sum && sum < 50){
      if(r>=50){
	printf("C\n");
      }else{
	printf("D\n");
      } 
    }else if(sum < 30){
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
import java.util.*;

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) System.out.println(C);
		if(C==B) System.out.println(A);
		if(A==C) System.out.println(B);
	}
}

Measured memory_bytes: 23508
#include<iostream>
#include<vector>
#include<algorithm>
#define N 1000000007
typedef unsigned long long ll;

using namespace std;

void MakeInit(vector<ll>*);
ll Calculate(vector<ll>&, vector<ll>&);

int main(){
  int i, n, r, a, b;
  vector<ll> data1, data2;

  MakeInit(&data1);

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=1; i<=n; ++i) data2.push_back(i);

    cin >> r;
    for(i=0; i<r; ++i){
      cin >> a >> b;
      swap(data2[a-1], data2[b-1]);
    }
    reverse(data2.begin(), data2.end());

    cout << Calculate(data1, data2) << endl;
    data2.clear();
  }
  return 0;
}

void MakeInit(vector<ll>* data){
  int i;
  ll x;
  for(i=1, x=1; i<=100000; ++i){
    x *= i;
    x %= N;
    data->push_back(x);
  }
}

ll Calculate(vector<ll>& data1, vector<ll>& data2){
  int i, a;
  ll ans;
  vector<ll> data3;
  vector<ll>::iterator j;
 
  for(i=data2.size()-1, ans=0; i>0; --i){
    j = upper_bound(data3.begin(), data3.end(), data2[i]);
    a = j - data3.begin();
    ans += (data1[i-1] * (data2[i] -a -1));
    ans %= N;
    data3.insert(j, data2[i]);
  }
  return ans;
}

Measured memory_bytes: 4488
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	a, b := readInt(), readInt()
	cnt := 0
	for i := a; i <= b; i++ {
		s := strconv.Itoa(i)
		frac := true
		for j := 0; j <= len(s)/2-1; j++ {
			if s[j] != s[len(s)-j-1] {
				frac = false
			}
		}
		if frac == true {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1152
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

int main(){

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5])Yes;
    else No;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
/*	int a1,a2,a3,b1,b2,b3;
	std::cin >> a1 >> b1;
	std::cin >> a2 >> b2;
	std::cin >> a3 >> b3;
*/
	int a[6];
	for (int i = 0; i < 6; i++) {
		std::cin >> a[i];
	}
	int count[5] = { 100,0,0,0,0 };

	for (int i = 0; i < 6; i++) {
		for (int j = 1; j < 5; j++) {
			if (a[i] == j) {
				count[j]++;
			}
		}
	}

	int flag = 0;
	for (int j = 1; j < 5; j++) {
		if (count[j] == 0 || count[j]==3) {
			flag = 1;
		}
	}

	if (flag == 1) {
		std::cout << "NO";
	}
	else {
		std::cout << "YES";
	}

}


Measured memory_bytes: 256
// AOJ NTL_1- A Elementary Number Theory - Prime Factorize
// 2017.10.31 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define SIZE  100
int factor[SIZE], size;

int ptbl[] = {
         3,   5,   7,  11,  13,  17,  19,  23,  29,
   31,  37,  41,  43,  47,  53,  59,  61,  67,  71,
   73,  79,  83,  89,  97, 101, 103, 107, 109, 113,
  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
  233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
  283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
  353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
  419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
  467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
  547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
  607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
  661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
  739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
  811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
  877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
  947, 953, 967, 971, 977, 983, 991, 997, 0 };

void prime_factor(int n)
{
  int i, d, sw;
  int *pp;

  size = 0;
  if ((n & 1) == 0) {
    do n >>= 1, factor[size++] = 2;
    while ((n & 1) == 0);
  }
  for (pp = ptbl; n > 1 && *pp > 0; pp++) {
    if (n % *pp) continue;
    d = *pp;
    do n /= d, factor[size++] = d;
    while (n % d == 0);
  }
  if (n > 1) {
    int b = (int)sqrt(n);
    for (i = 1009, sw = 0; n > 1; ) {
      if (i > b) {
        factor[size++] = n;
        break;
      }
      if (n % i == 0) {
        do n /= i, factor[size++] = i;
        while (n % i == 0);
      }
      if (sw) { i += 2, sw = 0; }
      else    { i += 4, sw = 1; }
    }
  }
}

int main()
{
	int n, i;

	scanf("%d", &n);
	prime_factor(n);
	printf("%d:", n);
	for (i = 0; i < size; i++) printf(" %d", factor[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1840
import sys
fastinput = sys.stdin.readline
H,W,D = [int(_) for _ in input().split()]
row=((H*W)//D+1)
modD = [[(0,0)]*row for i in range(D)] #modD[x][y]:x(modD)の数で商がyのやつの位置のタプル
for h in range(H):#0-indexed(0<=h<=H-1)
    A=[int(__) for __ in fastinput().split()]
    for w,a in enumerate(A):#めんどくさいのでマスの数も座標も0-indexed
        y,x = (a-1)//D,(a-1)%D
        modD[x][y]=(h,w)
costs=[[0]*row for i in range(D)]#コストの累積和
for d in range(D):
    pre=(0,0)
    curcos=0
    for k in range(row):
        now=modD[d][k]
        curcos += abs(now[0]-pre[0]) + abs(now[1]-pre[1])
        costs[d][k]=curcos
        pre=now
Q=int(input())
for _ in range(Q):
    s,g=[int(i)-1 for i in fastinput().split()]
    amari=s%D
    sRow,gRow=s//D,g//D
    print(costs[amari][gRow]-costs[amari][sRow])

Measured memory_bytes: 32936
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 3000

using namespace std;

int d[maxn+5][maxn+5], last[maxn+5][maxn+5];
queue<pii> qu;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s, t; cin >> s >> t;
  s = " "+s; t = " "+t;
  int i, j, z;
  for (i = 0; i <= maxn+1; i++)
    for (j = 0; j <= maxn+1; j++) d[i][j] = -inf;
  d[0][0] = 0; qu.push({0, 0});
  while (!qu.empty()) {
    pii cur = qu.front(); qu.pop();
    i = cur.fi; j = cur.se;
    if (i+1 < sz(s) && j+1 < sz(t) && s[i+1] == t[j+1] && d[i+1][j+1] < 1+d[i][j] ) {
      d[i+1][j+1] = 1+d[i][j];
      last[i+1][j+1] = 3;
      qu.push({i+1, j+1});
    }
    if (i+1 < sz(s) && d[i+1][j] < d[i][j]) {
      d[i+1][j] = d[i][j];
      last[i+1][j] = 1;
      qu.push({i+1, j});
    }
    if (j+1 < sz(t) && d[i][j+1] < d[i][j]) {
      d[i][j+1] = d[i][j];
      last[i][j+1] = 2;
      qu.push({i, j+1});
    }
  }
  string ans;
  i = sz(s)-1; j = sz(t)-1;
  while(last[i][j] != 0) {
    if (last[i][j] == 1) {
      if (d[i][j] > d[i-1][j]) ans.pb(s[i]);
      i--;
    } else if (last[i][j] == 2) {
      if (d[i][j] > d[i][j-1]) ans.pb(s[j]);
      j--;
    } else ans.pb(s[i]), i--, j--;
  }
  reverse(all(ans));
  cout << ans;
  return 0;
}


Measured memory_bytes: 70784
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[1010][1010];
vector<pair<int, int>> t[1010][1010];
int indeg[1010][1010];
int d[1010][1010];

int main(){
    cin >> n;
    REP(i, n){
        REP(j, n - 1){
            cin >> a[i][j];
            a[i][j]--;
            if(j){
                t[min((int)i, a[i][j - 1])][max((int)i, a[i][j - 1])].emplace_back(make_pair(min((int)i, a[i][j]), max((int)i, a[i][j])));
                indeg[min((int)i, a[i][j])][max((int)i, a[i][j])]++;
            }
        }
    }
    queue<pair<int, int>> q;
    REP(i, n){
        for(int j = i + 1;j < n;j++){
            if(indeg[i][j] == 0){
                q.push(make_pair(i, j));
                d[i][j] = 1;
            }
        }
    }
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int u = p.first, v = p.second;
        REP(i, (int)t[u][v].size()){
            indeg[t[u][v][i].first][t[u][v][i].second]--;
            d[t[u][v][i].first][t[u][v][i].second] = max(d[t[u][v][i].first][t[u][v][i].second], d[u][v] + 1);
            if(indeg[t[u][v][i].first][t[u][v][i].second] == 0){
                q.push(make_pair(t[u][v][i].first, t[u][v][i].second));
            }
        }
    }
    REP(i, n){
        for(int j = i + 1;j < n;j++){
            if(indeg[i][j] != 0){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    int ans = 0;
    REP(i, n){
        for(int j = i + 1;j < n;j++){
            ans = max(ans, d[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 51712