akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

#define MAXN 50
#define BOMB -1

using namespace std;

int A[MAXN][MAXN];
int H, W;

bool judge ( int x, int y )
{
  if ( x >= 0 && x < W && y >= 0 && y < H && A[y][x] != BOMB ) {
    ++A[y][x];
    return true;
  }
  else return false;
}

void bomb ( int x, int y )
{
  A[y][x] = BOMB;
  judge(x-1,y-1); judge(x,y-1); judge(x+1,y-1);
  judge(x-1,y);                 judge(x+1,y);
  judge(x-1,y+1); judge(x,y+1); judge(x+1,y+1);
}

int main()
{
  string s;
  int h = 0;
  int w = 0;
  char c;

  cin >> H >> W;
  getchar();

  while ( h < H ) {
    while ( w <= W ) {
      scanf("%c", &c);
      if ( c == '#' ) bomb(w,h);
      ++w;
    }
    w = 0;
    ++h;
  }

  for ( int i = 0; i < H; ++i ) {
    for ( int j = 0; j < W; ++j ) {
      if ( A[i][j] != BOMB ) cout << A[i][j];
      else cout << '#';
    }
    cout << "\n";
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(void)
{
	string k, m;
	int n, cnt = 0,a;
	cin >> k >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> m;
		m = m + m;
		a = m.find(k);
		if(a>=0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3204
// Ok it's fine bro  
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		sort(ar,ar+n);
		int ans =1;
		fn{
			if(ans > 1e18L/ar[i])
				return cout<<"-1",0;
			ans*=ar[i];
			if(ans==0)break;
		}
		cout <<ans;
	
	
	}
	return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define N 26
using namespace std;
int main() {
  int n;
  cin >> n;
  string S;
  vector<vector<int>> counter(n,vector<int>(N));
  for (int i = 0; i < n; i++) {
    cin >> S;
    for (char c : S) {
      counter[i][c-'a']++;
    }
  }
  for (int i = 0; i < N; i++) {
    int m = counter[0][i];
    for (int j = 1; j < n; j++) {
      m = min(m,counter[j][i]);
    }
    cout << string(m,(char)(i+'a'));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
#define endl '\n'

int32_t main()
{
 
  IOS
  int n;
  cin>>n;
  n%=10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n== 9){
    cout<<"hon";
  }
  else if(n == 3){
    cout<<"bon";
  }
  else{
    cout<<"pon";  
  }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
typedef pair<LL, LL> pLL;
// LatexBegin
struct MCMF { LL flow, cost;
  struct Node : vector<int> { int p, inq; LL a, d; };
  struct Edge { int u, v; LL c, co; };
  vector<Node> N; vector<Edge> E;
  void init(int n) {
    N.clear(); N.resize(n); E.clear(); flow = cost = 0;
  }
  void addEdge(int u, int v, LL c, LL co) {
    int m = E.size();
    E.push_back({u, v, c,  co}); N[u].push_back(m++); 
    E.push_back({v, u, 0, -co}); N[v].push_back(m++);
  }
  void run(int s, int t) {
    while (SPFA(s, t)) {
      flow += N[t].a; cost += N[t].d * N[t].a;
      for (int u = t ; u != s ; u = E[N[u].p].u) {
        E[N[u].p    ].c -= N[t].a;
        E[N[u].p ^ 1].c += N[t].a;
      }
    }
  }
  bool SPFA(int s, int t) {
    for (auto &v : N) v.d = INF, v.inq = false;
    queue<int> q; q.push(s); N[s].inq = true;
    N[s].d = 0, N[s].p = -1, N[s].a = INF;
    while (q.size()) {
      int u = q.front(); q.pop(); N[u].inq = false;
      for (auto &e : N[u]) { int v = E[e].v;
        if (!E[e].c || N[v].d <= N[u].d + E[e].co)
          continue;
        N[v].d = N[u].d + E[e].co;
        N[v].p = e; N[v].a = min(N[u].a, E[e].c);
        if (!N[v].inq) q.push(v), N[v].inq = true;
      }
    }
    return N[t].d != INF;
  }
} solver;
// LatexEnd
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    solver.init(1 + 2 * n + 1);
    for (int i = 0 ; i < n ; i++) {
        solver.addEdge(0, 1 + i, k, 0);
        solver.addEdge(1 + n + i, 1 + n + n, k, 0);
        solver.addEdge(1 + i, 1 + n + n, INF, 0);
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++) {
            LL v; cin >> v;
            solver.addEdge(1 + i, 1 + n + j, 1, -v);
        }
    }
    solver.run(0, 1 + n + n);
    cout << -solver.cost << '\n';
    auto E = solver.E;
    vector<vector<char>> G(n, vector<char>(n, '.'));
    for (int i = 0 ; i < (int)E.size() ; i += 2) {
        int u = E[i].u, v = E[i].v;
        if (u == 0 || v == 1 + n + n)
            continue;
        if (E[i].c) continue;
        u--, v--, v -= n;
        G[u][v] = 'X';
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++)
            cout << G[i][j];
        cout << '\n';
    }
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int h,w,n;cin>>h>>w>>n;
    vector<int>a(n);
    vector<vector<int> >ans(h,vector<int>(w));
    rep(i,n)cin>>a[i];
    ll now=0;
    rep(i,h){
        rep(j,w){
            if(!a[now])now++;
            ans[i][j]=now+1;
            a[now]--;
        }
    }
    rep(i,h){
        if(i%2)reverse(all(ans[i]));
    }
    rep(i,h){
        rep(j,w-1){
            cout<<ans[i][j]<<' ';
        }
        cout<<ans[i][w-1]<<endl;
    }
}

Measured memory_bytes: 384
from collections import deque
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
routes = [set() for _ in range(N)]
for _ in range(M):
    A, B = inpl()
    A -= 1
    B -= 1
    routes[A].add(B)
    routes[B].add(A)

pool = deque([0])
ans = [-1] * N
ans[0] = 0
while pool:
    n = pool.popleft()
    for c in routes[n]:
        if ans[c] < 0:
            ans[c] = n
            pool.append(c)
print('Yes')
for i in range(1,N):
    print(ans[i]+1)


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

int main(){
  int a[41]={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};
  int x;
  cin >> x;
  int ans=0;
  int i=0;
  while(i<41 && a[i] <= x ){
    ans = a[i];
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int x,y,temp;
        while(true){
            String str[] = br.readLine().split(" ");
            x = Integer.parseInt(str[0]);
            y = Integer.parseInt(str[1]);
            if(x == 0 && y == 0) break;
            if(x > y){
                temp = y;
                y = x;
                x = temp;
            }
            sb.append(Integer.toString(x)).append(" ").append(Integer.toString(y)).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26788
input_time = list(map(int, input().split()))
sum_time_l = 200
for i in range(3):

    if i + 1 == 3:
        sum_time = input_time[i] + input_time[0]
    else:
        sum_time = input_time[i] + input_time[i + 1]
    if sum_time_l > sum_time:
        sum_time_l = sum_time

print(sum_time_l)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int p=1000000007;
long long s[200003],ans,q[200003];
int n,m;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        scanf("%lld",&s[i]);
        q[i]=(s[i]+q[i-1])%p;
    }
    for(int i=2;i<=n;++i)
    {
        ans=(ans+(s[i]*(q[i-1])%p)%p)%p;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6940
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
int calc(int y){
}

// LookUp Version
const int N = 1000000;
int eulerPhi(int n) {
  static int lookup = 0, p[N], f[N];
  if (!lookup) {
    REP(i,N) p[i] = 1, f[i] = i;
    for (int i = 2; i < N; ++i) {
      if (p[i]) {
        f[i] -= f[i] / i;
        for (int j = i+i; j < N; j+=i)
          p[j] = 0, f[j] -= f[j] / i;
      }
    }
    lookup = 1;
  }
  return f[n];
}

void naive(int x,int y){
	int pos = -1 , len = -1;
	map<int,int> loop;
	int l = 0;
	while( 1 ){
		loop[x] = l++;
		x = x * 10;
		x %= y;
		if( loop.count(x) ){
			pos = loop[x];
			if( !x ) len = 0;
			else len = l - loop[x];
			break;
		}
	}
	cout << pos << " " << len << endl;
}

char use[1000100];
int answer[1000100];
#include <cstring>
int calclen(int y){
	//if( answer[y] ) return answer[y];
	memset(use,0,y);
	int c = 1;
	int len = 0;
	while( use[c] == 0 ){
		use[c] = 1;
		c = c * 10 % y;
		len++;
	}
	return answer[y] = len;
}
int smart(int x,int y){
	int g = __gcd(x,y);
	x /= g;
	y /= g;
	int chk = y;
	int two = 0 , five = 0;
	while( chk % 2 == 0 ) chk /= 2, two++;
	while( chk % 5 == 0 ) chk /= 5, five++;
	int pos = max(two,five);
	if( chk == 1 ){
		cout << pos << " " << 0 << endl;
		return 0;
	}
	cout << pos << " " << calclen(chk) << endl;
}
int main(){
	int x,y;
	map<int ,pair<int,int> > o;
	
	while( cin >> x >> y && x){
		//naive(x,y);
		smart(x,y);
		
	}
}

Measured memory_bytes: 5704
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> wow;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		wow[tmp]++;
	}
	vector<int> gew;
	for (auto i = wow.begin();i != wow.end();++i) {
		gew.push_back(i->second);
	}
	if (gew.size() > k) {
		int ans = 0;
		sort(gew.begin(), gew.end());
		for (int i = 0;i < gew.size() - k;++i) {
			ans += gew[i];
		}
		cout << ans << endl;
	}
	else cout << 0 << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i=0; i<n/2; i++){
        if(s.at(i) != s.at(n-1-i)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())


Patti = [1]  # レベルLバーガーに含まれているパティの数
Size = [1]   # レベルLバーガーの大きさ
for i in range(50):
    Patti.append(Patti[-1] * 2 + 1)
    Size.append(Size[-1] * 2 + 3)


def solve(n, x):
    # 一番下のバンのみ（ただしレベル0バーガーはPになる）
    if x == 1:
        return 0 + (n == 0)

    # 一番下のバン + レベルL-1バーガーのどこかまで
    if 1 < x <= 1 + Size[n - 1]:
        return solve(n - 1, x - 1)

    # 一番下のバン + レベルL-1バーガー + 真ん中のパティまで
    if x == 1 + Size[n - 1] + 1:
        return Patti[n - 1] + 1

    # 一番下のバン + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガーの途中まで
    if 1 + Size[n - 1] + 1 < x < Size[n]:
        return 1 + Patti[n - 1] + solve(n - 1, x - (1 + Size[n - 1] + 1))

    # レベルLバーガーすべて
    if x == Size[n]:
        return Patti[n]


print(solve(N, X))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
for(int i=0;i<3;i++){
int h1,m1,s1,h2,m2,s2,ans;
cin>>h1>>m1>>s1>>h2>>m2>>s2;
ans = ((h2*3600)+(m2*60)+s2)-((h1*3600)+(m1*60)+s1);
cout<<ans/3600<<" "<<(ans%3600)/60<<" "<<(ans%3600)%60<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#ABC084C
N=int(input())
csf=[]
for n in range(N-1):
	csf.append(list(map(int,input().split())))
for nn in range(N):
	#print(nn)
	t=0
	for n in range(nn,N-1):
		#print(" ",n)
		if t>csf[n][1]:
			t=csf[n][1]+((t-csf[n][1]+csf[n][2]-1)//csf[n][2])*csf[n][2]+csf[n][0]
			#t=S+((t-S+F-1)//F)*F+C
		else:
			t=csf[n][1]+csf[n][0]
		#print(" ",t)
	print(t)

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))

buy = 0
money = 1000
for i in range(N-1):
    if buy != 0:
        money += buy*A[i]
        buy = 0

    if A[i] < A[i+1]:
        buy = money // A[i]
        money -= buy * A[i]

if buy != 0:
    money += buy*A[-1]

print(money)

Measured memory_bytes: 8992
N,M = map(int,input().split()) 
dic = {}
for i in range(N):
  tmp = str(i+1)
  dic[tmp] = 0

for i in range(M):
  s = input().split()
  a = s[0]
  b = s[1]
  dic[a] += 1
  dic[b] += 1
   
for i in range(N):
  tmp = str(i+1)
  print(dic[tmp])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;


int main() {
    vector<int> dp(1000001),s(1000001);
    s.at(0)=0;
    queue<int> q;
    q.push(1);
    while (!q.empty()){
        int a=q.front();
        q.pop();
        if (a>1000000) continue;
        dp[a]=1;
        q.push(a*2);
        q.push(a*3);
        q.push(a*5);
    }
    for (int i=1;i<1000001;i++){
        s.at(i)=s.at(i-1)+dp.at(i);
    }
    while (true){
    int t,y;
    cin >> t;
    if (t==0) return 0;
    cin >>y;
    cout << s.at(y)-s.at(t-1) << endl;
}
}



Measured memory_bytes: 15980
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int f[10000005];

signed main(){
    FASTER;
    f[1]++;
    for(int i=2;i<=1e7;i++){
        f[i]++;
        for(int j=i;j<=1e7;j+=i){
            f[j]++;
        }
    }
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=i*f[i];
    }
    cout<<ans;
}



Measured memory_bytes: 81780
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    flag = True
    for a in A:
        if a % 2 == 1:
            flag = False
            break
            
    if flag:
        print('second')
    else:
        print('first')


if __name__ == "__main__":
    main()

Measured memory_bytes: 80684
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
#define y1 yyyy1111
using namespace std;
int dp[2005][2005],maxi[2005],lst[2005][2005],ma;
V<P<int,int> > v;
void ch(int x,int y,int x1,int y1,int p){
	if(x>y)swap(x,y);
	if(x1>y1)swap(x1,y1);
	gmax(dp[x][y],lst[x1][y1]+p);
	v.PB(MP(x,y));
}
void sol(int x,int y,int y1){
	if(x>y)swap(x,y);
	gmax(dp[x][y],y1);
	v.PB(MP(x,y));
}
void kk(){
	for(auto u:v){
		gmax(maxi[u.F],dp[u.F][u.S]);
		gmax(maxi[u.S],dp[u.F][u.S]);
		gmax(ma,dp[u.F][u.S]);
	}
	v.clear();
}
void p(int x,int y){
	if(x>y)swap(x,y);
	lst[x][y]=dp[x][y];
}
int a[6005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i,1,3*n)cin>>a[i];
	FOR(i,1,n)FOR(j,i,n)dp[i][j]=-1e9;
	FOR(i,1,n)maxi[i]=-1e9;
	ch(a[1],a[2],0,0,0);kk();
	int cnt=0;
	rep(i,1,n){
		int s[3];
		rep(j,0,3)s[j]=a[i*3+j];
		FOR(j,1,n){
			p(j,s[0]);p(j,s[1]);p(j,s[2]);
		}
		sort(s,s+3);
		if(s[0]==s[1]&&s[1]==s[2]){
			cnt++;continue;
		}
		if(s[0]==s[1]){
			ch(s[0],s[1],s[2],s[2],1);
			FOR(j,1,n){
				ch(s[2],j,j,s[0],1);
			}
		}else if(s[1]==s[2]){
			ch(s[1],s[2],s[0],s[0],1);
			FOR(j,1,n){
				ch(s[0],j,j,s[1],1);
			}
		}else{
			ch(s[1],s[2],s[0],s[0],1);
			ch(s[0],s[2],s[1],s[1],1);
			ch(s[0],s[1],s[2],s[2],1); 
		}
		FOR(j,1,n){
			rep(k,0,3){
				sol(j,s[k],maxi[j]);
			}
		}
		rep(j,0,3){
			rep(k,j+1,3){
				sol(s[j],s[k],ma);
			}
		}
		kk(); 
	}
	int ans=0;
	FOR(i,1,n){
		FOR(j,i,n)gmax(ans,dp[i][j]);
	} 
	gmax(ans,dp[a[3*n]][a[3*n]]+1);
	cout<<ans+cnt;
	RE 0;
}


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

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

int n;
int d[6] = {1,2,6,5,3,4};

void init_dice(void) {
    d[0]=1;d[1]=2;d[2]=6;d[3]=5;d[4]=3;d[5]=4;
}

/*
void printDice(void) {
    rep(i,6) {
        cout<<d[i];
        if(i==5) cout<<"\n";
        else cout<< " ";
    }
}
*/

void North(void) {
    int t1=d[0],t2=d[3];
    d[0]=d[1]; d[1]=d[2];
    d[2]=t2; d[3]=t1;
}

void South(void) {
    int t1=d[0],t2=d[1];
    d[0]=d[3]; d[3]=d[2];
    d[1]=t1; d[2]=t2;
}

void East(void) {
    int t1=d[0],t2=d[4];
    d[0]=d[5]; d[5]=d[2];
    d[2]=t2; d[4]=t1;
}

void West(void) {
    int t1=d[0],t2=d[5];
    d[0]=d[4]; d[4]=d[2];
    d[2]=t2; d[5]=t1;
}

void Left(void) {
    int t1=d[1];
    d[1]=d[5]; d[5]=d[3];
    d[3]=d[4]; d[4]=t1;
}

void Right(void) {
    int t1=d[1];
    d[1]=d[4]; d[4]=d[3];
    d[3]=d[5]; d[5]=t1;
}


int main() {
    while(cin>>n && n) {
        init_dice();
        int ans = 1;
        rep(i,n) {
            string s; cin>>s;
            if(s == "North") North();
            if(s == "South") South();
            if(s == "East") East();
            if(s == "West") West();
            if(s == "Left") Left();
            if(s == "Right") Right();
            //printDice();
            ans += d[0];
        }
        cout << ans << "\n";
    }

    
    return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.rbegin(), a.rend());
    int max_a = a[0];

    sort(b.rbegin(), b.rend()); 

    int count = 0;
    int idx = 0;
    while(b[idx] > max_a && h > 0) {
        h -= b[idx];
        count++;
        idx++;
    }

    while(h > 0) {
        h -= max_a;
        count++;
    }

    cout <<count << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int arr[n+1],count=0;
    arr[0]=0;
   for(int i=1;i<n;i++)
   {
   cin>>arr[i];
   if(arr[i]!=i)
   count++;
   }
   if(count>2)
   cout<<"NO";
   else
   cout<<"YES";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#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 ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int MAX_D = 300000;
vector<int> doyo(MAX_D+7,0);


int main(){

  for(int i = 0;i<MAX_D;i+=7){
    doyo[i+1] = 1;
    doyo[i+6] = 1;
  }
  doyo[1] = 0;
  for(int i = 1;i*i<MAX_D;i++){
    if(doyo[i])
      for(int j = i*2;j<MAX_D ;j+=i)
	if(doyo[j]){
	  doyo[j] = 0;}

  }
  
  int num;
  while(true){
    cin >> num;
    if(num==1)break;
    cout << num << ':';
    for(int i = 6;i<num+1;i++){
      if(doyo[i] && num % i == 0)
	cout << ' ' << i;
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3668
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete


main = do
    n <- getInt
    as <- sortBy (flip compare) <$> getInts
    print $ sum $ zipWith (*) as $ cycle [1,-1]

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

int main(){
    int n;
    cin >> n;
    
    map<int, int> mp;
    
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        
        mp[a]++;
    }
    
    int ans = 0;
    
    for (auto p : mp){
        if (p.second % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt();
        pw.println(n >= 30 ? "Yes" : "No");
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32888
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long N, S; cin >> N >> S;
	vector<long long> Sum(N + 1,0);
	for (int i = 1; i <= N;i++) {
		int a; cin >> a;
		Sum[i] += Sum[i - 1] + a;
	}
	long long ans = LLONG_MAX;
	int left = 0, right = 0;
	while (true) {
		if (Sum[right] - Sum[left] >= S) {
			ans = (ans < right - left) ? ans : right - left;
			left++;
		}
		else right++;
		if (right > N || left > N) { if (ans == LLONG_MAX)ans = 0; cout << ans << endl; return 0; }
	}
}

Measured memory_bytes: 3612
s = str(input())
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

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

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

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

    int num = 0, ans = 0;

    for (int i = n-1; i >= 0; i--) {
        if (num == data[i]) {
            num--;
        } else {
            if (data[i] <= i && num < data[i]) {
                ans += data[i];
                num = data[i]-1;
            } else {
                ans = -1;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}








Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	char x;
	cin >> x;
	if (x >= 65 && x <= 90)
	{
		cout << "A" << en;
	}
	else
	{
		cout << "a" << en;
	}



	return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int k, a, b; scanf("%d%d%d", &k, &a, &b);
	FOR(i, a, b+1) if(i%k==0){
		printf("OK\n");
		return 0;
	}
	printf("NG\n");
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = int(3e3) + 3;
const int mod = int(1e9) + 7;

int f[N][N], n, q, a[N], x, y, div2;

int Pow(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1) res = 1ll * res * x % mod;
        x = 1ll * x * x % mod;
    }
    return res;
}

int sum(int x, int y) {if((x += y) >= mod) x -= mod; return x;}
int mul(int x, int y) {return 1ll * x * y % mod;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> q; div2 = Pow(2, mod - 2);
    for(int i = 1; i <= n; ++i) cin >> a[i];
    /// f(i, j) -> ai > aj
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) f[i][j] = a[i] > a[j];
    }
    for(int i = 1; i <= q; ++i) {
        cin >> x >> y;
        f[x][y] = f[y][x] = mul(sum(f[x][y], f[y][x]), div2);
        for(int j = 1; j <= n; ++j) {
            if(j == x || j == y) continue;
            f[x][j] = f[y][j] = mul(sum(f[x][j], f[y][j]), div2);
            f[j][x] = f[j][y] = mul(sum(f[j][x], f[j][y]), div2);
        }
    }
    int res = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j) {
            res += f[i][j];
            if(res >= mod) res %= mod;
        }
    cout << mul(res, Pow(2, q));
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
const double PI=acos(-1);

int main(){
    double r;
    cin>>r;

    cout<<fixed<<setprecision(10)<<r*r*PI<<" "<<r*2*PI<<endl;
}


Measured memory_bytes: 3272
nk=input().rstrip().split(" ")
n=int(nk[0])
k=int(nk[1])
hps=input().rstrip().split(" ")
for i in range(n):
    hps[i]=int(hps[i])
shps=sorted(hps)
#print(shps)
answer=0
for i in range(n-k):
    answer+=int(shps[i])
print(answer)


Measured memory_bytes: 19652
h, w= map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
B = [list(map(int, input().split())) for _ in range(h)]

C = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        C[i][j] = abs(A[i][j]-B[i][j])

import numpy as np
d = 80*(h+w-1)
D = 2*d+1
dp = [[0]*w for j in range(h)]
dp[0][0] = np.zeros(D, np.bool)
dp[0][0][d+C[0][0]] = 1
for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            continue
        x = np.zeros(D, np.bool)
        if i != 0:
            x[C[i][j]:] |= dp[i-1][j][:D-C[i][j]]
            x[:D-C[i][j]] |= dp[i-1][j][C[i][j]:]
        if j != 0:
            x[C[i][j]:] |= dp[i][j-1][:D-C[i][j]]
            x[:D-C[i][j]] |= dp[i][j-1][C[i][j]:]
        dp[i][j] = x

temp = np.where(dp[-1][-1]>0)[0] - d
temp = abs(temp)
print(min(temp))

Measured memory_bytes: 172868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int a[11];

int dfs(int left,int right,int cnt){
  //cout<<left<<" "<<right<<" "<<cnt<<endl;
  if(cnt==10)return cnt;
  if(left<a[cnt]&&right<a[cnt]) cnt=max(dfs(a[cnt],right,cnt+1),dfs(left,a[cnt],cnt+1));
  else if(left<a[cnt])cnt=dfs(a[cnt],right,cnt+1);
  else if(right<a[cnt]) cnt=dfs(left,a[cnt],cnt+1);
  
  return cnt;
}

int main(){
  int n;
  cin>>n;
  rep(i,n){
    rep(j,10)cin>>a[j];
    //rep(j,10)cout<<a[i]<<" ";
    //cout<<endl;
    if(dfs(a[0],-INF,1)==10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

#define ll long long

using namespace std;

bool end(string s){
    char temp = s[0];
    for(int i = 1;i < s.length();i++){
        if(temp != s[i])return false;
        temp = s[i];
    }
    return true;
}

int alpha[26];
int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int j = 0;j < 26;j++){
        int oldpoint = 0;
        alpha[j] = -1;
        int max = 0;
        for(int i = 0;i < s.length();i++){
            if(oldpoint == 0 && s[i] == 'a'+j){
                oldpoint = i;
                max = i;
            }
            else if(s[i] == 'a'+j){
                if(max < i - oldpoint)max = i - oldpoint;
                oldpoint = i;
            }
        }
        if(max < s.length() - oldpoint)max = s.length() - oldpoint;
        alpha[j] = max != 0 ? max :  99999;
        //cout << max << endl;
    }
    char mostalpha = 'a';
    int min = 999999;
    int maxcount = 0;
    //最大文字がどれか
    for(int i = 0;i < 26;i++){
        if(min > alpha[i]){
            min = alpha[i];
            mostalpha = 'a' + i;
            maxcount=1;
        }else if(min == alpha[i]){
            maxcount++;
        }
        //cout << min << endl;
    }
    //cout << mostalpha << endl;
    // if(max == 1){
    //     mostalpha = s[s.length()/2];
    // }
    while(!end(s)){
        string t = "";
        for(int i = 0;i < s.length() - 1;i++){
            if(s[i] == mostalpha){
                t += mostalpha;
            }else if(s[i+1] == mostalpha){
                t += mostalpha;
            }else{
                t += s[i];
            }
        } 
        s = t;
        ans++;
        //cout << s << endl;
    }
    cout << ans << endl;
	return 0;
}        


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

int main() {
  int N;
  int count=0;
  cin >> N;
  for (int i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    count += r-l+1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int i,j,k;
	char m[5][9][9];
	memset(m,0,sizeof(m));
	for(i=0;i<8;i++)scanf("%s",m[0][i]);
	for(k=0;k<3;k++){
		printf("%d\n",90*(k+1));
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				m[k+1][j][7-i]=m[k][i][j];
			}
		}
		for(i=0;i<8;i++)printf("%s\n",m[k+1][i]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    ll ans = n * (ll) n;
    for (int b = 1; b <= n; b++)
    {
        for (int cur = 0; cur <= n; cur += b)
        {
            int en = min(n, cur + b - 1);
            int dist = min(en - cur + 1, k);
            ans -= dist;
        }
    }
    for (int b = 1; b <= n; b++)
    {
        if (0 % b < k) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> dts(n);
    for(int i = 0; i < n; i++){
        int t, d;
        cin >> t >> d;
        dts[i] = {d, t};
    }
    sort(dts.rbegin(), dts.rend());
    set<int> eaten;
    ll acc = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    for(int i = 0; i < k; i++){
        acc += dts[i].first;
        if(eaten.count(dts[i].second)){
            pq.push(dts[i].first);
        }else{
            eaten.insert(dts[i].second);
        }
    }
    ll ans = acc + eaten.size() * eaten.size();
    for(int i = k; i < n; i++){
        if(pq.empty()){ break; }
        printde(eaten);
        int t = dts[i].second;
        if(!eaten.count(t)){
            eaten.insert(t);
            acc -= pq.top(); pq.pop();
            acc += dts[i].first;
            ll cand = acc + ll(eaten.size() * eaten.size());
            printde(ans, cand);
            ans = max(ans, cand);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[M];
    int C[N+1];
    for(int i = 0; i < M; i++){
        cin >> A[i];
    }
    sort(A,A+M);

    int costL = distance(A,lower_bound(A,A+M,X));
    int costR = M - costL;

    if(costL > costR){
        cout << costR << endl;
    }else{
        cout << costL << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    int n;
    cin >> n;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;        
        if (a % 2) c++;
    }
    if (c % 2 == 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
declare var require: (x: string) => any;

const MOD = 1000000007;

function mul(x: number, y: number){
  if (x == 1) return y;
  if (y == 1) return x;
  if (x == 0 || y == 0) return 0;
  let ans = 0;
  while(y > 0){
    ans += x * (y%100) % MOD;
    ans %= MOD;
    x = x * 100 % MOD;
    y = Math.floor(y/100);
  }
  return ans;
}

function Main(input: string[]) {
  const s = input[0];
  const n = s.length;

  let aa = new Uint32Array(n);
  let cc = new Uint32Array(n);
  let qq = new Uint32Array(n);

  let totalq = s[0]=='?' ? 1 : 0;

  aa[0] = s[0]=='A' ? 1 : 0;
  qq[0] = s[0]=='?' ? 1 : 0;
  for(let i = 1; i < n; i++){
    if (s[i] == 'A'){
      aa[i] = aa[i-1] + 1;
    } else {
      aa[i] = aa[i-1];
    }

    if(s[i] == '?'){
      qq[i] = qq[i-1] + 1;
      totalq++;
    } else {
      qq[i] = qq[i-1];
    }
  }

  cc[n-1] = s[n-1]=='C' ? 1 : 0;
  for(let i = n - 2; i >= 0; i--){
    if (s[i] == 'C'){
      cc[i] = cc[i+1] + 1;
    } else {
      cc[i] = cc[i+1];
    }
  }

  let pow3 = new Uint32Array(n);
  pow3[0] = 1;
  for(let i = 1; i < n; i++) {
    pow3[i] = pow3[i-1]*3;
    while(pow3[i] >= MOD) pow3[i] -= MOD;
  }

  let ans = 0;
  for (var i = 1; i < n-1; i++) if(s[i]=='?' || s[i]=='B'){
    let lv = mul(aa[i-1], pow3[qq[i-1]]);
    if(qq[i-1] > 0) lv += mul(qq[i-1], pow3[qq[i-1]-1]);
    lv %= MOD;

    let rq = totalq - qq[i];
    let rv = mul(cc[i+1], pow3[rq]);
    if(rq > 0) rv += mul(rq, pow3[rq - 1]);
    rv %= MOD;

    // console.log(i, aa[i], qq[i], cc[i], lv, rv, rq, n, totalq);

    ans += mul(lv, rv);
    ans %= MOD;
  }

  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
vector<pair<lli, lli>> p;
int n;
map<lli, map<lli, lli>> f;
lli calc(lli pp, lli qq) {
  bool v[55] = {};
  int ans = 0;
  rep(i, n) {
    if (v[i])
      continue;
    v[i] = true;
    lli xx = p[i].first, yy = p[i].second;
    while (true) {
      xx += pp;
      yy += qq;
      if (f[xx][yy]) {
        v[f[xx][yy]] = true;
      } else {
        break;
      }
    }
    ans++;
  }
  return ans;
}
int main() {
  cin >> n;
  lli x, y;
  rep(i, n) {
    cin >> x >> y;
    p.push_back(make_pair(x, y));
  }
  sort(p.begin(), p.end());
  rep(i,n)f[p[i].first][p[i].second] = i;
  lli ans = n;
  rep(i, n) rep(j, i) {
    lli pp = p[i].first - p[j].first;
    lli qq = p[i].second - p[j].second;
    if (pp == 0 && qq == 0)
      continue;
    ans = min(ans, calc(pp, qq));
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s in dic.keys():
    dic[s] += 1
  else:
    dic[s] = 1

m = int(input())
for i in range(m):
  t = input()
  if t in dic.keys():
    dic[t] -= 1
    
ans = 0
for key in dic.keys():
  ans = max(ans, dic[key])
  
print(max(ans, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
ll n,m,i,x,y,c=0;
cin>>n>>m;
ll arr[n+2]={0};
for(i=0;i<m;i++)
{
    cin>>x>>y;
    arr[x]++;
    arr[y+1]--;
}
for(i=1;i<=n;i++)
{
    arr[i]=arr[i]+arr[i-1];
    if(arr[i]==m)
        c++;
}
cout<<c<<endl;
}


Measured memory_bytes: 1024
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
 
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
if k in a:
  print "POSSIBLE"
else:
  c=a[:]
  while len(a)!=1:
    b=a.pop()
    a[0]=gcd(a[0],b)
  print "POSSIBLE" if k%a[0]==0 and max(c)>=k else "IMPOSSIBLE"

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

ll n;
ll dp[e5][64];

ll s[e5];
char acgt[] = {'A','C','G','T'};

int main(){
  cin >> n;


  // if(n == 3) cout << 61 << endl;
  // else if(n == 4) cout << 230 << endl;
  if(false){}
  else{
    dp[0][0] = 1;
    for(ll i = 1;i <= n;i++){
      for(ll j = 0;j < 64;j++){
        dp[i][((j << 2) + 0)%64] += dp[i-1][j];
        dp[i][((j << 2) + 1)%64] += dp[i-1][j];
        if((j%16) != 7) dp[i][((j << 2) + 2)%64] += dp[i-1][j];
        if((j%16) != 6 && (j%16) != 9 && (j/4) != 6 && j != 18 && j != 26) dp[i][((j << 2) + 3)%64] += dp[i-1][j];
      }
      for(ll j = 0;j < 64;j++){
        dp[i][j] %= mod;
      }
    }
    cout << accumulate(dp[n],dp[n]+64,0ll)%mod << endl;
  }

}


Measured memory_bytes: 2304