akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
  string S;
  int N,length;
  cin>>N>>S;
  length=S.size();
  for(int i=0;i<N;i++){
    for(int j=0;j<length;j++){
      if(S[j]=='A')S[j]='B';
      else if(S[j]=='B')S[j]='C';
      else if(S[j]=='C')S[j]='D';
      else if(S[j]=='D')S[j]='E';
      else if(S[j]=='E')S[j]='F';
      else if(S[j]=='F')S[j]='G';
      else if(S[j]=='G')S[j]='H';
      else if(S[j]=='H')S[j]='I';
      else if(S[j]=='I')S[j]='J';
      else if(S[j]=='J')S[j]='K';
      else if(S[j]=='K')S[j]='L';
      else if(S[j]=='L')S[j]='M';
      else if(S[j]=='M')S[j]='N';
      else if(S[j]=='N')S[j]='O';
      else if(S[j]=='O')S[j]='P';
      else if(S[j]=='P')S[j]='Q';
      else if(S[j]=='Q')S[j]='R';
      else if(S[j]=='R')S[j]='S';
      else if(S[j]=='S')S[j]='T';
      else if(S[j]=='T')S[j]='U';
      else if(S[j]=='U')S[j]='V';
      else if(S[j]=='V')S[j]='W';
      else if(S[j]=='W')S[j]='X';
      else if(S[j]=='X')S[j]='Y';
      else if(S[j]=='Y')S[j]='Z';
      else if(S[j]=='Z')S[j]='A';
    }
  }
  cout<<S<<endl;
}


Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, counter = 0, x;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (x % 2 == 1 && i % 2 == 1)
			counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3604
#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); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> snuke(N,0);
    rep(i,K){
        int d;
        cin >> d;
        rep(j,d){
            int okashi;
            cin >> okashi;
            okashi--;
            snuke[okashi]++;
        }
    }
    int cnt = 0;
    rep(i,N){
        if (snuke[i] == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

let int_of_digit c = int_of_char c - 48 (* 48 = int_of_char '0' *)

(* O(log(n)) *)
let sum_digits n =
  let rec loop sofar m =
    if m <= 0 then
      sofar
    else
      loop (sofar + m mod 10) (m / 10)
  in
    loop 0 n

(* O(n * log(n)) *)
let solve n a b =
  fold_int
    (fun sum i ->
      let i = i + 1 in
      let d = sum_digits i in
      sum + if a <= d && d <= b then i else 0)
    0
    n

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [n; a; b] -> solve n a b |> string_of_int |> print_endline
  | _ -> ()

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

int main()
{
	string s;
	cin >> s;
	bool ans = true;
	auto found = vector<bool>('z' + 1);
	for(auto c : s){
		if(found[c]){
			ans = false;
			break;
		}
		found[c] = true;
	}
	cout << (ans ? "yes" : "no") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll,ll>
#define mk make_pair
using namespace std;
const int N = 10005;
ll a[N];
map<ll,P>mp;
int main()
{
    for(ll i=0;i<=1000;i++){
        ll y = i;
        for(ll x=1;x<=4;x++){
            y = y * i;
        }
        a[i] = y;
    }
    for(int i=0;i<=1000;i++){
        for(int j=0;j<=1000;j++){
             mp[a[i]-a[j]] = mk(i,j);
             mp[a[i]+a[j]] = mk(i,-j);
        }
    }
    ll x;
    cin >> x;
    cout << mp[x].first << ' ' << mp[x].second << '\n';
    return 0;
}


Measured memory_bytes: 97492
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}



Measured memory_bytes: 2088
import java.util.*;
import java.io.*;

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 



	public static void main(String[] args) {
		// Scanner sc = new Scanner(System.in);
		FastReader fr = new FastReader();
		int N = fr.nextInt();
		int count = 0;
		
		String st = fr.next();

		char[] chars = st.toCharArray();
		int i = 0;
		int j = N-1;

		for (; i < N; i++) {
			if (chars[i] == 'W') {
				for (; j > i; j--) {
					if (chars[j] == 'R') {
						char temp = chars[i];
						chars[i] = chars[j];
						chars[j] = temp;
						count++;
						break;
					}
				}
			}
		}

		System.out.println(count);	
	}
}

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

int main(){
    int H,N; cin >> H >> N;
    vector <int> A(N);
    int sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    } 
    
    if (sum>=H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;
ll n,m;
int main()
{

	ios::sync_with_stdio(0);

	cin>>n;
	m=1;
	for(int i=1;i<=3;i++)
	{
		m*=n;
	}
	cout<<m<<endl;
return 0;
}




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

int main()
{
  double W, H;
  pair<double, double> p_in, p_centre;

  cin >> W >> H >> p_in.first >> p_in.second;

  double menseki;
  menseki = W * H / 2.0;
  p_centre.first = W / 2.0;
  p_centre.second = H / 2.0;

  cout << menseki;
  if (p_centre.first == p_in.first && p_centre.second == p_in.second)
  {
    cout << ' ' << 1 << endl;
  }
  else
  {
    cout << ' ' << 0 << endl;
  }

  return 0;

}

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

ll a[maxn];
vector<ll> h[maxn];
int main(){
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++){//各个塔的高度 
    	cin>>a[i];
	}
	ll aa,bb;
	for(ll i=1;i<=m;i++){//表示从哪条路能到哪条路 
		cin>>aa>>bb;
		h[aa].push_back(bb);
		h[bb].push_back(aa);
	}
	ll tot = 0;
	int flag;
	for(ll i=1;i<=n;i++){//对塔遍历 
	flag = 0;
	if(h[i].size()==0){
		tot++;
		continue;
	} 
	for(ll j=0;j<h[i].size();j++){
			if(a[i] > a[h[i][j]]){
				flag++;
				
			}
		}
		if(flag==h[i].size()) tot++;
	}
    cout<<tot<<endl;
	return 0;
} 

Measured memory_bytes: 10240
N = int(input())
h = list(map(int, input().split()))
# print(N, h)

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10 ** 5 + 10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    # 一番目の足場では一つ前しか存在しない 
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 52680
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
void func(int at,int forb, vector<pair<int, pair<int, int>>> &edge, vector<vector<pair<int, int>>> &path){
	int res=1;
	repi(itr,path[at]){
		if(res==forb){
			res++;
		}
		if(edge[itr->F].F!=-1){
			continue;
		}
		edge[itr->F].F=res;
		res++;
		func(itr->S,res-1,edge,path);
	}
}

	int main()
{
	int n;
	cin >>n;
	vector<vector<pair<int,int>>>path(n);
	vector<pair<int,pair<int,int>>>edge(n-1);
	int a,b;
	int k=0;
	rep(i,n-1){
		cin>>a>>b;
		a--;
		b--;
		edge[i]=mp(-1,mp(a,b));
		path[a].emplace_back(i,b);
		path[b].emplace_back(i, a);
	}
	rep(i,n){
		chmax(k,(int)path[i].size());
	}	
	cout<<k<<endl;
	func(0,-1,edge,path);
	rep(i,n-1){
		cout<<edge[i].F<<endl;
	}
}

Measured memory_bytes: 11600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	set<ll> s;
	rep(i,n)cin>>v[i];
	ll t=0;
	ll ss=0;
	rep(i,n){
		rep(j,i){
			if(v[j]>v[i])t++;
		}
	}
	rep(i,n){
		rep(j,n){
			if(v[j]<v[i])ss++;
		}
	}
	ll kk=((((k*(k-1))/2)%MOD)*ss)%MOD;
	cout<<((t*k)%MOD+kk)%MOD<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

signed main() {
    ll n; 
    cin >> n;
    
    int flg = 0;
    
    ll a, b;
    
    ll r = 1;
    
    rep(i, n) {
        cin >> a;
        if (i > 0) {
            if (b > a) {
                if (flg == -1) {
                    r++;
                    flg = 0;
                } else flg = 1;
            }
            if (b < a) {
                if (flg == 1) {
                    r++;
                    flg = 0;
                } else flg = -1;
            }
        }
        b = a;
    }
    
    mes(r);
    
    
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<int> A;
    vector<bool> exist(n + 5, false);
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        A.push_back(a);
    }
    vector<int> minus(n), plus(n);
    for (int i = 0; i < n; i++) {
        minus[i] = i - A[i];
        plus[i] = i + A[i];
    }
    sort(minus.begin(), minus.end());
    sort(plus.begin(), plus.end());
    ll ans = 0;
    for (auto x: plus) {
        auto top = upper_bound(minus.begin(), minus.end(), x);
        auto bottom = lower_bound(minus.begin(), minus.end(), x);
        ans += top - bottom;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    map<int, int> mp;
    mp[0]++;
    
    rep(i, n){
        int d; cin >> d;
        mp[d]++;
    }
    
    vi ans;
    vi cand;
    for(auto [k, v] : mp){
        // cout << k << " " << v << endl;    
        if(v >= 3) {
            cout << 0 << endl;
            return;
        }else if(v == 2){
            if(k == 0 || k == 12){
                cout << 0 << endl;
                return;
            }else{
                ans.pb(k);
                ans.pb(24 - k);
            }
        }else{
            if(k == 0 || k == 12){
                ans.pb(k);
            }else{
                cand.pb(k);
            }
        }
    }
    
    int mx = 0;
    int s = cand.size();
    rep(bit, 1 << s){
        vi tmp = ans;
        rep(i, s){
            if(bit >> i & 1){
                // 右に置く
                tmp.pb(cand[i]);
            }else{
                // 左に置く
                tmp.pb(24 - cand[i]);
            }
        }
        sort(all(tmp));
        int res = 12;
        rep(i, tmp.size()){
            int t;
            if(i == tmp.size() - 1){
                t = min(tmp[i] - tmp[0], 24 - (tmp[i] - tmp[0]));
            }else{
                t = min(tmp[i+1] - tmp[i], 24 - (tmp[i+1] - tmp[i]));
            }
            res = min(res, t);
        }
        
        mx = max(mx, res);
    }

    cout << mx << endl;    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3660
from collections import deque

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())

c = [input().rstrip() for _ in range(H)]

d = deque([(x1-1, y1-1)])

dp = [[-1] * W for _ in range(H)]
dp[x1-1][y1-1] = 0

while d:
    x, y = d.popleft()
    if x == x2-1 and y == y2-1:
        print(dp[x][y])
        break

    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for i in range(1, K+1):
            nx = x + dx * i
            ny = y + dy * i

            if 0 > nx or nx >= H or 0 > ny or ny >= W or c[nx][ny] == '@':
                break

            if dp[nx][ny] == -1:
                dp[nx][ny] = dp[x][y] + 1
                d.append((nx, ny))
            elif dp[nx][ny] <= dp[x][y]:
                break
else:
    print(-1)


Measured memory_bytes: 92488
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

a, b, c= load_list()
print("%d %d %d" % (c, a, b))



Measured memory_bytes: 38256
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
        self.numEs = [0] * numV
    def find(self, x):
        if self.pars[x] == x: return x
        else:
            self.pars[x] = self.find(self.pars[x])
            return self.pars[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            self.numEs[x] += 1
        elif self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += self.sizes[x]
            self.numEs[y] += self.numEs[x] + 1
        else:
            self.pars[y] = x
            self.sizes[x] += self.sizes[y]
            self.numEs[x] += self.numEs[y] + 1
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(M)]

UF = UnionFind(N)
for A, B in ABs:
    UF.union(A-1, B-1)

for v in range(N):
    UF.find(v)

par1 = UF.find(0)
par2 = UF.find(1)
pars = set(UF.pars)
sizeOther = numEOther = 0
for par in pars:
    if par == par1:
        size1 = UF.sizes[par]
        numE1 = UF.numEs[par]
    elif par == par2:
        size2 = UF.sizes[par]
        numE2 = UF.numEs[par]
    else:
        sizeOther += UF.sizes[par]
        numEOther += UF.numEs[par]

size = size1 + sizeOther
numE = numE1 + numEOther
ans1 = size*(size-1)//2-numE + size2*(size2-1)//2-numE2
size = size2 + sizeOther
numE = numE2 + numEOther
ans2 = size*(size-1)//2-numE + size1*(size1-1)//2-numE1

print(max(ans1, ans2))


Measured memory_bytes: 29080
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll fact[100005];

int N, K;
ll A[100005];

void init_fact() {
    ll f = 1;
    fact[0] = 1;
    for (int i = 1; i <= 100004; i ++) {
        f = (f * i) % MOD;
        fact[i] = f;
    }
}

void extgcd(ll a, ll b, ll *x, ll *y) {
    ll xx, yy;
    if (b == 0) {
        *x = 1;
        *y = 0;
    } else {
        ll q = a / b;
        ll r = a % b;
        extgcd(b, r, &xx, &yy);
        *x = yy;
        *y = xx - q * yy;
    }
}

ll inv(ll a) {
    ll x, y;
    extgcd(a, MOD, &x, &y);
    return (x + MOD) % MOD;
}

ll combination(int n, int r) {
    return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD;
}

int main() {
    init_fact();
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 0;
    for (int i = K - 1; i < N; i ++) {
        ll c = combination(i, K - 1);
        ans = (ans + c * A[i] % MOD) % MOD;
    }
    for (int i = 0; i <= N - K; i ++) {
        ll c = combination(N - 1 - i, K - 1);
        ans = (ans + MOD - c * A[i] % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
use std::io::stdin;

fn main() {
    let (a, b) = get_param();
    println!("{}", solve(a, b));
}

fn get_param() -> (i32, i32) {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut ab = s.split_whitespace();
    let a = ab.next().unwrap().parse().unwrap();
    let b = ab.next().unwrap().parse().unwrap();
    (a, b)
}

fn solve(a: i32, b: i32) -> &'static str {
    if a * b % 2 == 0 {
        "Even"
    } else {
        "Odd"
    }
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int h, w, k;
    cin >> h >> w >> k;
    char s[301][301] = {};
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    Int a[301][301] = {};
    Int cnt = 1;
    for (Int i = 0; i < h ;i++) {
        for (Int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                a[i][j] = cnt;
                cnt++;
            }
        }
    }
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w - 1; j++) {
            if (a[i][j] > 0 && a[i][j + 1] == 0) {
                a[i][j + 1] = a[i][j];
            }
        }
    }
    for (Int i = 0; i < h; i++) {
        for (Int j = w - 1; j > 0; j--) {
            if (a[i][j] > 0 && a[i][j - 1] == 0) {
                a[i][j - 1] = a[i][j];
            }
        }
    }
    for (Int i = 0; i < h - 1; i++) {
        for (Int j = 0; j < w; j++) {
            if (a[i][j] > 0 && a[i + 1][j] == 0) {
                a[i + 1][j] = a[i][j];
            }
        }
    }
    for (Int i = h - 1; i > 0; i--) {
        for (Int j = 0; j < w; j++) {
            if (a[i][j] > 0 && a[i - 1][j] == 0) {
                a[i - 1][j] = a[i][j];
            }
        }
    }
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cout << a[i][j] << " " ;
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	string e, out = "";
	getline(cin, e);
	
	stack<int> s;
	int temp1 = 0, temp2 = 0;
	
	for(int i = 0; i < e.size(); i++)
	{
		if(e[i] == ' ')
		{
			if(out != "")
			{
				stringstream stoi(out);
				stoi >> temp1;
				s.push(temp1);
				out = "";
			}
		}
		else if(e[i] == '+')
		{
			temp2 = s.top();
			s.pop();
			temp1 = s.top();
			s.pop();
			s.push(temp1 + temp2);
		}
		else if(e[i] == '-')
		{
			temp2 = s.top();
			s.pop();
			temp1 = s.top();
			s.pop();
			s.push(temp1 - temp2);
		}
		else if(e[i] == '*')
		{
			temp2 = s.top();
			s.pop();
			temp1 = s.top();
			s.pop();
			s.push(temp1 * temp2);
		}
		else
		{
			out += e[i];
		}
	}
	
	printf("%d\n", s.top());
	
	return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

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



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

    vector<ll> H(N + 1, 0);
    repn(i, N) cin >> H[i];
    H[0] = 1;

    vector<vector<mint>> dp(N + 1, vector<mint>(N + 1, 0));
    mint x;

    rep(j, N + 1) {
        if (H[j] == 1) { dp[0][j] = 1; }
    }

    repn(i, N)rep(j, N+1) {

        //if (H[i] == 1) {
            //if(H[j]<=H[i]){dp[i][j]== }
        //}
        if (H[i] <= H[i - 1]) {
            if (H[j] <= H[i]) { dp[i][j] = dp[i - 1][j] + dp[i - 1][i]; }
            else { dp[i][j] = 0; }
        }

        else {
            if (H[j] <= H[i - 1]) { dp[i][j] = ((mint)2^(H[i] - H[i - 1])) * (dp[i - 1][j] + dp[i - 1][i - 1]);}
            else if (H[j] <= H[i]) { dp[i][j] = ((mint)2^(H[i] - H[j])) * 2 * dp[i - 1][i - 1]; }
            else { dp[i][j]=0; }
        }
        //cout << i << j << " "<<dp[i][j] << endl;
    }

    cout << dp[N][0];

	system("PAUSE");
}

Measured memory_bytes: 512
n = int(input())

school = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    school[b - 1][f - 1][r - 1] += v

for blg in range(4):
    for flr in range(3):
        for rm in range(10):
            print (" %d" % school[blg][flr][rm], end = "")
        print ()
    if blg < 3:
        print ("#" * 20)



Measured memory_bytes: 5624
d1=[0 for i in range(6)]
d1[:]=(int(x) for x in input().split())
t1=[0 for i in range(6)]
order=input()
for i in range(len(order)):
  if order[i]=='N':
    t1[0]=d1[1]
    t1[1]=d1[5]
    t1[2]=d1[2]
    t1[3]=d1[3]
    t1[4]=d1[0]
    t1[5]=d1[4]
  if order[i]=='S':
    t1[0]=d1[4]
    t1[1]=d1[0]
    t1[2]=d1[2]
    t1[3]=d1[3]
    t1[4]=d1[5]
    t1[5]=d1[1]
  if order[i]=='E':
    t1[0]=d1[3]
    t1[1]=d1[1]
    t1[2]=d1[0]
    t1[3]=d1[5]
    t1[4]=d1[4]
    t1[5]=d1[2]
  if order[i]=='W':
    t1[0]=d1[2]
    t1[1]=d1[1]
    t1[2]=d1[5]
    t1[3]=d1[0]
    t1[4]=d1[4]
    t1[5]=d1[3]
  
  d1=list(t1)

print(d1[0])


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

int main() {
    while(true) {
        string S;
        cin >>S;
        if ("0"==S)
            break;
        int SS=0;
        for (int i=0; i<S.size(); i++)
            SS +=S.at(i)-'0';
        cout <<SS <<endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
int main()
{
	char s[11]={0,0,0,0,0,0,0,0,0,0,0},t[11]={0,0,0,0,0,0,0,0,0,0,0},u[11]={0,0,0,0,0,0,0,0,0,0,0};
	int a,b;
	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",u);
	if(u[0]==s[0]&&u[1]==s[1]&&u[2]==s[2]&&u[3]==s[3]&&u[4]==s[4]&&u[5]==s[5]&&u[6]==s[6]&&u[7]==s[7]&&u[8]==s[8]&&u[9]==s[9]&&u[10]==s[10])a--;
  	else if(u[0]==t[0]&&u[1]==t[1]&&u[2]==t[2]&&u[3]==t[3]&&u[4]==t[4]&&u[5]==t[5]&&u[6]==t[6]&&u[7]==t[7]&&u[8]==t[8]&&u[9]==t[9]&&u[10]==t[10]) b--;
    printf("%d %d\n",a,b);
    return 0;
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int n;
ll a[100001][3];
ll dp[100001][3]={0};
/*
int solve(int sum, int select,int cnt){
    if(cnt==n)return sum;
    int ans=0;
    rep(i,0,3){
        if(select==i)continue;
        ans=max(ans,solve(sum+a[cnt][i],i,cnt+1));
    }
    return ans;
}
*/
int main(void){
    cin>>n;
    rep(i,0,n){
        rep(j,0,3)cin>>a[i][j];
    }

    rep(i,0,n){
        rep(j,0,3){
            rep(k,0,3){
                if(j==k)continue;
                dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    //cout<<solve(0,-1,0)<<endl;

    ll ans=0;
    rep(i,0,3)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    char b;
    cin >> b;
    if (b == 'A'){
        cout << 'T' << endl;
    }else if(b == 'T'){
        cout << 'A' << endl;
    }else if(b == 'G'){
        cout << 'C' << endl;
    }else{
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
n,k = map(int,input().split())
d = list(map(int,input().split()))
def ok(x):
    x = str(x)
    for i in range(len(x)):
        if int(x[i]) in d:
            return False
    return True
for i in range(n,10**5):
    if ok(i):
        print(i)
        break

Measured memory_bytes: 40796
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll d,g; cin >> d >> g;
    g /= 100;
    vl nxt(d);
    rep(i,d) nxt[i] = i;
    vl p(d),c(d);
    rep(i,d) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    ll ans = INF;
    do{
        ll cnt = 0;
        ll score = g;
        rep(i,d){
            ll t = nxt[i];
            if(p[t]*(t+1)+c[t]>=score){
                cnt += min(p[t],(score+t)/(t+1));
                break;
            }
            cnt += p[t];
            score -= p[t]*(t+1) + c[t];
        }
        //cout << cnt << endl;
        ans = min(cnt, ans);
    }while(next_permutation(all(nxt)));
    cout << ans << endl;
}

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

bool zorome(int a){
  int th=a/100;
  int tw=(a%100)/10;
  if(th!=tw) return false;
  int on=a%10;
  if(tw!=on) return false;
  else return true;
}

int main(){
  int N; cin>>N;
  while(!zorome(N))
    N++;
  cout<<N<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const char names[11][16] = {
    "light fly",
    "fly",
    "bantam",
    "feather",
    "light",
    "light welter",
    "welter",
    "light middle",
    "middle",
    "light heavy",
    "heavy"
};
const double weights[11] = {
    48.00,
    51.00,
    54.00,
    57.00,
    60.00,
    64.00,
    69.00,
    75.00,
    81.00,
    91.00,
    1e100,
};

int main() {
    double w;
    while (scanf("%lf", &w) != EOF) {
        int ix = 0;
        while (ix < 10 && w > weights[ix]) ix++;
        puts(names[ix]);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)

int main(){

	double dp[302][302][302]={};
	int n;
	cin >> n;
	int a[4]={};
	FOR(i,0,n){
		int k;
		cin >> k;
		a[k]++;
	}
/*
x,y,z->1,2,3個の皿の個数　のときの期待値をdp[x][y][z] とする
dp[x][y][z] = dp[x-1][y][z] * x/n
			+dp[x+1][y-1][z] *y/n
			+dp[x][y+1][z-1] *z/n
			+dp[x][y][z] *(n-x-y-z)/n
			+ 1
dp[x][y][z]の項を左辺に移項して
(x+y+z)/n*dp[x][y][z] = dp[x-1][y][z] * x/n
				+dp[x+1][y-1][z] *y/n
				+dp[x][y+1][z-1] *z/n
				+ 1

  	式を見ると
  	zが小さい方、yが小さい方、xが小さいものから決まっていく
*/
	FOR(z,0,n+1){
		FOR(y,0,n+1){//FOR(y,0,a[2]+1)としないように
			FOR(x,0,n+1){//FOR(x,0,a[1]+1)としないように
				if(x==0&&y==0&&z==0)continue;
				if(x>0)dp[x][y][z] += dp[x-1][ y][ z] * (double)x/(double)n;
				if(y>0)dp[x][y][z] += dp[x+1][y-1][z] * (double)y/(double)n;
				if(z>0)dp[x][y][z] += dp[x][y+1][z-1] * (double)z/(double)n;
				dp[x][y][z] += 1.0;
				dp[x][y][z] /= double(x+y+z)/(double)n;
			}
		}
	}
	cout << setprecision(15) << dp[a[1]][a[2]][a[3]] << endl;
}


Measured memory_bytes: 215424
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

short cost[110][110];
short time_data[110][110];


int main(){
	short n, m;


	while (cin >> n >> m && (n != 0 && m != 0)) {
		short min_ = 20000; // 答えの最小値
		short min_num = 1; // 答えの町

		short from, to, time_, cost_;
		short k;
		short k_from, k_to, info;

		for (short i = 1; i < 110; i++) {
			for (short j = 1; j < 110; j++) {
				if (i == j) {
					cost[i][j] = 0;
					time_data[i][j] = 0;
				} else {
					cost[i][j] = 20000;
					time_data[i][j] = 20000;
				}
			}
		}
		for (short i = 0; i < n; i++) {
			cin >> from >> to >> cost_ >> time_;
			cost[from][to] = cost_;
			cost[to][from] = cost_;
			time_data[from][to] = time_;
			time_data[to][from] = time_;
		}
		for (short k = 1; k <= m; k++) {
			for (short i = 1; i <= m; i++) {
				for (short j = 1; j <= m; j++) {
					cost[i][j] = min((int)cost[i][j], cost[i][k] + cost[k][j]);

					time_data[i][j] = min((int)time_data[i][j], time_data[i][k] + time_data[k][j]);
				}
			}
		}
		// 答えを求める
		cin >> k;
		for (short i = 0; i < k; i++) {
			cin >> k_from >> k_to >> info;
			if (info == 0) {
				cout << cost[k_from][k_to] << endl;
			} else {
				cout << time_data[k_from][k_to] << endl;
			}
		}
		
  }
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  string S;
  cin >> S;
  int N = S.size();
  bool east, west, north, south;
  east = west = north = south = false;
  rep(i, N) {
    if (S[i] == 'E')
      east = true;
    else if (S[i] == 'W')
      west = true;
    else if (S[i] == 'N')
      north = true;
    else if (S[i] == 'S')
      south = true;
  }

  if (east != west || north != south)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


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

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);

	    
	int n,m; ll k; cin>>n>>m>>k;
	ll a[n+1],b[m+1];
	a[0] = b[0] = 0;
	for(ll i=1;i<n+1;i++){ 
	    cin>>a[i];
	    a[i] =a[i]+ a[i-1];
	}
	
	for(ll i=1;i<m+1;i++){
	    cin>>b[i];
	    b[i] =b[i]+ b[i-1];
	}
	int count = 0;
	int ind1 = n, ind2 = 0;
	while(ind1>=0 && ind2<=m)
	{
		while(ind1>=0 && a[ind1]+b[ind2]>k) ind1--;
		while(ind2<=m && a[ind1]+b[ind2]<=k) ind2++;
		ind2--;
		count = max( count , ind1 + ind2 );
		ind2++;
	}
	ind1 = 0, ind2 = m;
	while(ind1<=n && ind2>=0)
	{
		while(ind2>=0 && a[ind1]+b[ind2]>k) ind2--;
		while(ind1<=n && a[ind1]+b[ind2]<=k) ind1++;
		ind1--;
		count = max( count , ind1 + ind2 );
		ind1++;
	}

    cout<<count<<endl;

return 0;

}

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

int main() {
  string a;
  cin >> a;
  int counter = 0;
  
  if (a[0] == '1')++counter;
  if (a[1] == '1')++counter;
  if (a[2] == '1')++counter;
  
  cout << counter << endl;

  
  }


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

int main()
{
    int n;
    int a[1010];

    cin >> n;

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

    for(int i=1; i<n; i++)
    {
        cout << a[n-i] << ' ';
    }
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 5005;
int n, p[N], fac[N];
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
void rem(int &x, int y) {
	x -= y;
	if (x < 0) x += mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fpow(int a, int p) {
	if (!p) return 1;
	int tmp = fpow(a, p >> 1);
	tmp = mul(tmp, tmp);
	if (p & 1) tmp = mul(tmp, a);
	return tmp;
}
struct DSU {
	int p[N], sz[N];
	void init(int n) {
		fw (i, 0, n) {
			p[i] = i;
			sz[i] = 1;
		}
	}
	int getp(int u) {
		return u == p[u] ? u : p[u] = getp(p[u]);
	}
	bool joint(int u, int v) {
		u = getp(u), v = getp(v);
		if (u == v) return false;
		if (sz[u] < sz[v]) swap(u, v);
		p[v] = u;
		sz[u] += sz[v];
		return true;
	}
	int getSize(int u) {
		return sz[getp(u)];
	}
} dsu;
int dp[N][N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	fw (i, 1, N) fac[i] = mul(fac[i - 1], i);
	cin >> n;
	dsu.init(n);
	int cntCycles = 0, cntUndecided = 0;
	fw (i, 0, n) {
		cin >> p[i];
		if (p[i] != -1) p[i]--;
		if (p[i] >= 0) {
			bool success = dsu.joint(i, p[i]);
			if (!success) cntCycles++;
		} else cntUndecided++;
	}
	vector<int> trees;
	fw (i, 0, n) if (p[i] == -1) {
		trees.pb(dsu.getSize(i));
	}
	int ans = mul(n - cntCycles, fpow(n - 1, cntUndecided));
	dp[0][0] = 1;
	fw (i, 0, trees.size()) fw (j, 0, i + 1) if (dp[i][j]) {
		add(dp[i + 1][j], dp[i][j]);
		add(dp[i + 1][j + 1], mul(dp[i][j], trees[i]));
	}
	fw (j, 1, cntUndecided + 1) {
		int ways = mul(dp[cntUndecided][j] - (j == 1) * cntUndecided, fac[j - 1]);
		int other = cntUndecided - j;
//		cout << "ways = " << ways << " other = " << other << "\n";
		rem(ans, mul(ways, fpow(n - 1, other)));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 70472
#include <iostream>
#include <vector>

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

vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> bList(M);
    for (auto i = 0; i < M; i++) {
        cin >> bList.at(i);
    }

    int res = 0;
    for(int i = 0; i < N; i++) {
        int sum = C;
        for(int j = 0; j < M; j++) {
            int a;
            cin >> a;
            sum += a * bList.at(j);
        }
        if (sum > 0) res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;

template<typename T>
struct Seg{
private:
    vector<T> node;
    int n;
    function<T(T,T)> f;
    T def;

public:
    Seg(int siz, T d, function<T(T,T)> f) : def(d), f(f) {
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, def);
    }
    Seg(vector<T> v, T d, function<T(T,T)> f) : def(d), f(f){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void update(int x, T val){
        x += n-1;
        node[x] = val; /* ! */
        while(x){
            x = (x-1)/2;
            node[x] = f(node[2*x+1], node[2*x+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(b <= l || r <= a)    return def;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

int main(){
    int n, v, p;
    ll m;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    sort(a.begin(), a.end());
    Seg<ll> seg(a, 0ll, [](ll x, ll y){return x+y;});
    ll target = a[n-p];
    int l = -1, r = n-1;
    while(r-l > 1){
        int mid = (l+r)/2;
        // 元々上からp番目以内に入っている
        if(n-mid <= p){
            r = mid;
            continue;
        }
        if(a[mid]+m < target){
            l = mid;
            continue;
        }
        ll afford = m*(lower_bound(a.begin(),a.end(),a[mid])-a.begin());
        afford += (p-1)*m;
        int x = lower_bound(a.begin(),a.end(),a[mid])-a.begin();
        afford += (ll)(n-p-x+1-1)*(a[mid]+m)-seg.query(x, n-p+1)+a[mid];
        if(afford >= m*(v-1))   r = mid;
        else                    l = mid;
    }
    cout << n-r << endl;
    return 0;
}

Measured memory_bytes: 3840
#include    <stdio.h>

int main(void)
{
  int a, b;

  scanf("%d %d", &a, &b);
  if (a == b) {
    puts("a == b");
  } else if (a < b) {
    puts("a < b");
  } else {
    puts("a > b");
  }

  return 0;
}

Measured memory_bytes: 580
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {

            int n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 == 0 || i.ToString().Contains("3"))
                {
                    Console.Write($" {i}");
                }
            }
            Console.WriteLine();


        }
    }
}



Measured memory_bytes: 18004
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

s = input()
t = input()
n = len(t)
if t[:n-1] == s:print('Yes')
else:
    print('No')


Measured memory_bytes: 72688
S = input()

ans = False

if S[:7] == "keyence":
    ans = True

if S.find("k") != -1:
    if S.find("keyenc") == 0 and S[-1] == "e":
        ans = True
    if S.find("keyen") == 0 and S[-2:] == "ce":
        ans = True
    if S.find("keye") == 0 and S[-3:] == "nce":
        ans = True
    if S.find("key") == 0 and S[-4:] == "ence":
        ans = True
    if S.find("ke") == 0 and S[-5:] == "yence":
        ans = True
    if S.find("k") == 0 and S[-6:] == "eyence":
        ans = True
    if S[-7:] == "keyence":
        ans = True
if ans:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#!usr/bin/perl
chomp($len=<>);chomp($_=<>);
$len = ($len % 2) ? 0 : $len/2;
$a = $_;
s/(.{$len})(.{$len})/\2\1/;
if($_ eq $a && $len != 0){print "Yes";}
else{print "No";}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<int> p(N);
    REP(i,N){
        cin>>p[i];p[i]--;
    }
    int res=0;
    REP(i,N-1){
        if(p[i]==i){
            int tmp=i;
            p[i]=p[i+1];
            p[i+1]=i;
            res++;
        }
    }
    if(p[N-1]==N-1)res++;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
num = int(input())
a = num // 1000
b = num % 1000 // 100
c = num % 100 //10
d = num % 10

if a + b + c + d == 7:
  print(a, "+", b, "+", c, "+", d, "=", 7, sep='')
elif a + b + c - d == 7:
  print(a, "+", b, "+", c, "-", d, "=", 7, sep='')
elif a + b - c + d == 7:
  print(a, "+", b, "-", c, "+", d, "=", 7, sep='')
elif a + b - c - d == 7:
  print(a, "+", b, "-", c, "-", d, "=", 7, sep='')
elif a - b + c + d == 7:
  print(a, "-", b, "+", c, "+", d, "=", 7, sep='')
elif a - b + c - d == 7:
  print(a, "-", b, "+", c, "-", d, "=", 7, sep='')
elif a - b - c + d == 7:
  print(a, "-", b, "-", c, "+", d, "=", 7, sep='')
else:
  print(a, "-", b, "-", c, "-", d, "=", 7, sep='')


Measured memory_bytes: 3064