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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        if (n < 4) return 1;

        var r = 0;

        for(int i=2; i <= n; i++) {
            int y = i*i;
            while(y<=n) {
                r = Math.Max(r, y);
                y *= i;
            }
        }

        return r;
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ret = (r[0] + (r[1] - 1)) / r[1];
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, a;
	set<int> A;
	cin >> n;
	rep(i, n)
	{
		cin >> a;
		A.insert(a);
	}
	
	set<int>::iterator itr;
    for(itr = A.begin(); itr != A.end(); itr++) {
        if (itr != A.begin())
        {
            cout << " " ;
        }
        std::cout << *itr;
    }
	cout << endl;
}



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

struct node{
	int id;
	node *right,*left,*parent;
};

node*root;

bool find(int key){
	node*cur=root;
	while(cur!=NULL&&cur->id!=key){
		if(cur->id >key)	cur=cur->left;
		else cur=cur->right;
	}
	if(cur==NULL)	return false;
	else 	return true;
}

void insert(int k){
	node *y=NULL,*x=root,*z;
	z=(node*)malloc(sizeof(node));
	z->id=k;
	z->left=NULL;	z->right=NULL;
	while(x!=NULL){
		y=x;
		if(z->id > x->id)	x=x->right;
		else 	x=x->left;
	}
	z->parent=y;
	if(y==NULL)	root=z;
	else{
		if(z->id > y->id)	y->right=z;
		else 	y->left=z;
	}
}

void in(node *cur){
	if(cur==NULL)	return;
	in(cur->left);
	printf(" %d",cur->id);
	in(cur->right);
}
void pre(node *cur){
	if(cur==NULL)	return;
	printf(" %d",cur->id);
	pre(cur->left);
	pre(cur->right);
}

int main(){
	int n;	cin>>n;
	string command;
	int v;
	for(int i=0;i<n;i++){
		cin>>command;
		if(command[0]=='i'){
			cin>>v;
			insert(v);
		}
		else if(command[0]=='f'){
			cin>>v;
			if(find(v))	cout<<"yes"<<endl;
			else 	cout<<"no"<<endl;
		}
		else if(command[0]=='p'){
			in(root);	cout<<endl;
			pre(root);	cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19972
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int ans1, ans2;
    for (int i = 0; i < n; i++) {
        b.at(i) = a.at(i);
    }
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    ans1 = b.at(0);
    ans2 = b.at(1);
    if (ans1 == ans2) {
        for (int i = 0; i < n; i++) {
            cout << ans1 << endl;
        }
    }
    else {
        for (int i = 0; i < n; i++) {
            if (a.at(i) == ans1) {
                cout << ans2 << endl;
            }
            else cout << ans1 << endl;
        }
    }
}


Measured memory_bytes: 3200
#include<iostream>
#include<queue>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 4;
const int inf = (1<<20);
bool edge[N][N][N][N];
int cost[(1<<16)];
char m[N][N+1];

int encode(bool in[4][4]){
  int ret=0;
  rep(i,4){
    rep(j,4){
      if (in[i][j])ret|=((1<<(j+i*4)));
    }
  }
  return ret;
}

void decode(bool in[4][4],int now){
  rep(i,4){
    rep(j,4){
      in[i][j]=now%2==1;
      now/=2;
    }
  }
}

int fill(int t,int b,int l,int r,bool st[4][4],char color){
  bool cpy[4][4];
  rep(i,4)rep(j,4)cpy[i][j]=st[i][j];
  for(int i=t;i<=b;i++){
    for(int j=l;j<=r;j++){
      if (color == m[i][j])cpy[i][j]=true;
      else cpy[i][j]=false;
    }
  }
  return encode(cpy);
}

string color="RGB";
int solve(){
  bool st[4][4];
  rep(i,(1<<16))cost[i]=inf;
  queue<int> Q;
  Q.push(0);
  cost[0]=0;
  while(!Q.empty()){
    int now=Q.front();Q.pop();
    if (now == (1<<16)-1)return cost[now];
    decode(st,now);
    rep(i,4){
      REP(ii,i,4){
	rep(j,4){
	  REP(jj,j,4){
	    if (!edge[i][ii][j][jj])continue;
	    rep(l,4){
	      int next=fill(i,ii,j,jj,st,color[l]);
	      if (cost[next] == inf){
		cost[next]=cost[now]+1;
		Q.push(next);
	      }
	    }
	  }
	}
      }
    }

  }
  return -1;
}

void makePattern(int h,int w){
  for(int i=-3;i < 4;i++){//top
    if (i+h <= 0)continue;
    for(int j=-3;j < 4;j++){//left
      if (j+w <= 0)continue;
      int l=max(0,j),r=min(3,j+w-1),t=max(0,i),b=min(3,i+h-1);
      edge[t][b][l][r]=true;
      /*
      cout << i <<" " << j <<" " << w <<" " << h <<" can push " << l <<" - " << t <<" : " << r <<" - "<< b << endl;
      rep(ii,4){
	rep(jj,4){
	  if (t <= ii && ii <= b && l <= jj && jj <= r)cout << "1";
	  else cout <<"0";
	}
	cout << endl;
      }
      cout << endl;
      */
    }
  }
}

main(){
  int n;
  while(cin>>n){
    rep(i,4)rep(j,4)rep(k,4)rep(l,4)edge[i][j][k][l]=false;
    rep(i,n){
      int w,h;
      cin>>w>>h;
      makePattern(w,h);
    }
    rep(i,4)cin>>m[i];
    cout << solve() << endl;
  }
  return 0;
}

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
	operator int() const noexcept { return to; }
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T>
struct SCC{
	T g;
	Graph G,rG,nG;
	vector<vector<int>> scc;
	vector<int> cmp,used,vs;

	int operator[](int i) const{ return cmp[i]; }
	
	SCC(T g) : g(g),G(g.size()),rG(g.size()),cmp(g.size(),-1),used(g.size()){
		for(int i = 0;i < g.size();i++){
			for(const auto &e : g[i]){
				G[i].push_back((int)e);
				rG[(int)e].push_back(i);
			}
		}
	}

	void dfs(int v){
		used[v] = true;
		for(int to : G[v]) if(!used[to]) dfs(to);
		vs.push_back(v);
	}

	void rdfs(int v,int cnt){
		scc[cnt].push_back(v);
		cmp[v] = cnt;
		for(int to : rG[v]) if(cmp[to] == -1) rdfs(to,cnt);
	}

	void build(){
		int n = g.size(),cnt = 0;
		for(int i = 0;i < n;i++) if(!used[i]) dfs(i);
		reverse(vs.begin(),vs.end());
		for(int v : vs){
			if(cmp[v] == -1){
				scc.emplace_back();
				rdfs(v,cnt++);
			}
		}
		nG.resize(cnt);
		for(int i = 0;i < n;i++){
			for(const auto &e : g[i]){
				int u = cmp[i],v = cmp[(int)e];
				if(u != v) nG[u].push_back(v);
			}
		}
		for(int i = 0;i < cnt;i++){
			sort(nG[i].begin(),nG[i].end());
			nG[i].erase(unique(nG[i].begin(),nG[i].end()),nG[i].end());
		}
	}
};

signed main(){
	int n,m;
	cin >> n >> m;
	Graph G(n);
	for(int i = 0;i < m;i++){
		int s,t;
		cin >> s >> t;
		G[s].push_back(t);
	}
	SCC<Graph> scc(G);
	scc.build();
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		int u,v;
		cin >> u >> v;
		cout << (scc[u] == scc[v]) << endl;
	}
}


Measured memory_bytes: 5796
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam = in.nextInt();
		int nam2[] = {1,2,4,8,16,32,64};
	    
	    int memo = 0;
	    for(int i = 0;i < 7; i++){
	        if(nam>=nam2[i]){
	            memo = nam2[i];
	        }
	    }

        System.out.print(memo);
	}
}

Measured memory_bytes: 23124
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    string s;
    cin >> s;

    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }

    vector<bool> a(150, false);
    rep(i, (int)s.size()){
        a[s[i]] = true;
    }

    int c = -1;
    for(int i = 'a'; i <= 'z'; i++){
        if(!a[i]){
            c = i;
            break;
        }
    }

    if(c != -1){
        cout << s << (char)c << endl;
        return 0;
    }

    for(int i = (int)s.size()-1; i >= 0; i--){
        a[s[i]] = false;
        string t = s.substr(0, i);
        char cc = '\0';
        for(int j = 'a'; j <= 'z'; j++){
            if(a[j]){
                continue;
            }
            cc = j;
            t.push_back(cc);
            if(s.compare(t) < 0){
                cout << t << endl;
                return 0;
            }
            t.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 760
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    for i in range(N):
        if len(A)%2 == 0: # 1,1,3,3,...
            if A[i] != 1 + i//2*2:
                print(0)
                return
        else: # 0,2,2,4,4...
            if A[i] != (i+1)//2*2:
                print(0)
                return
    ans = 1
    for _ in range(N//2):
        ans *= 2
        ans %= 10**9+7
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13876
A=[int(i)*500 for i in range(0,int(input())+1)]
B=[int(i)*100 for i in range(0,int(input())+1)]
C=[int(i)*50 for i in range(0,int(input())+1)]
X=int(input())  
l=[]
for a in A:
  for b in B:
    for c in C:
      l.append(a+b+c)
print(l.count(X))    

Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> p(n);
    ll cnt=0;
    rep(i,n){
        cin>>p[i];
    }
    ll i=0;
    while(i<n){
        if(p[i]==i+1){
            if(i<n-1 && p[i+1]==i+2){
                cnt++;
                i++;
            }else cnt++;
        }
        i++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
def hantei(x,y):

    if y == 0:
        return "l"
    elif x == R:
        return "d"
    elif y == C:
        return "r"
    elif x == 0:
        return "u"

    return "n"

R,C,N = map(int,input().split())

u = []
l = []
d = []
r = []

for i in range(N):

    X1,Y1,X2,Y2 = map(int,input().split())

    if hantei(X1,Y1) != "n" and hantei(X2,Y2) != "n":


        if hantei(X1,Y1) == "l":
            l.append([X1,Y1,i])
        elif hantei(X1,Y1) == "d":
            d.append([X1,Y1,i])
        elif hantei(X1,Y1) == "r":
            r.append([X1,Y1,i])
        elif hantei(X1,Y1) == "u":
            u.append([X1,Y1,i])

        X1 = X2
        Y1 = Y2
    
        if hantei(X1,Y1) == "l":
            l.append([X1,Y1,i])
        elif hantei(X1,Y1) == "d":
            d.append([X1,Y1,i])
        elif hantei(X1,Y1) == "r":
            r.append([X1,Y1,i])
        elif hantei(X1,Y1) == "u":
            u.append([X1,Y1,i])

l.sort()
d.sort()
r.sort()
r.reverse()
u.sort()
u.reverse()

ps = []
for i in l:
    ps.append(i[2])
for i in d:
    ps.append(i[2])
for i in r:
    ps.append(i[2])
for i in u:
    ps.append(i[2])

q = []

for i in ps:
    if len(q) > 0 and q[-1] == i:
        del q[-1]
    else:
        q.append(i)

if len(q) == 0:
    print ("YES")
else:
    print ("NO")



Measured memory_bytes: 39044
// Active Infants 動的計画法　ソート
#include <bits/stdc++.h>
using namespace std;

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

int main(){
    int N;
    cin>>N;
    vector<long long> a(N);
    rep(i,N){
        cin>>a[i];
    }
 	vector<int> index(a.size());
	iota(index.begin(), index.end(), 0); // indexに0から順に代入
	sort(
        index.begin(),
        index.end(),
        [&](int x, int y){return a[x] > a[y];} // 降順
	);
    // a[]の順番は変わらない
 //   cout<<endl;
 //   rep(i,N){
 //       cout<<a[i]<<" "<<index[i]<<endl;
 //   }
    long long DP[N][N]={};
    DP[0][0]=0;
    int k;
    for(int i=1;i<=N;i++){
        for(int j=0;j<(i+1);j++){
            k=i-j;
            if(j>0 && k>0){
                if(DP[j-1][k]+a[index[i-1]]*(index[i-1]-(j-1))>DP[j][k-1]+a[index[i-1]]*((N-k)-index[i-1])){
                    DP[j][k]=DP[j-1][k]+a[index[i-1]]*(index[i-1]-(j-1));
                }
                else{
                    DP[j][k]=DP[j][k-1]+a[index[i-1]]*((N-k)-index[i-1]);
                }
            } 
            else if(j>0) {
                DP[j][k]=DP[j-1][k]+a[index[i-1]]*(index[i-1]-(j-1));
            }
            else {
                DP[j][k]=DP[j][k-1]+a[index[i-1]]*((N-k)-index[i-1]);
            }
 //           cout<<j<<" "<<k<<" "<<DP[j][k]<<endl;
        }
    }
 //   cout<<endl;
    long long ans=0;
    rep(i,N){
        int j=N-i;
        ans=max(ans, DP[i][j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 34872
N = int(input())

from itertools import product

def f(n):
    ret = 0
    i = 0
    while True:
        i += 1
        for v in product('357', repeat=i):
            v = ''.join(v)
            if int(v) > n:
                return ret
            if len(set(v)) == 3:
                ret += 1

print(f(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb(a) push_back(a)
#define arr(a) new ll int[a]
#define INF 1000000000000000000
#define MOD 4222236787
//ll int composite[15125];
const int N = 1e5 + 2;
ll fact[N];
void factorial(){
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < N; i++)
        fact[i] = (fact[i-1] * i) % MOD;
}
ll power(ll a, ll b, ll mod){
	ll x = 1, y = a;
	while (b > 0){
		if (b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}
ll modular_inverse(ll n, ll mod){
	return power(n, mod-2, mod);
}
ll nCr(ll n, ll k, ll mod){
	return (fact[n]*((modular_inverse(fact[k],MOD)*modular_inverse(fact[n-k],MOD))%mod))%mod;
}
//ll int arr1[10001];
//ll int arr1[25];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll int n=s.size();
    if(s[n-1]=='s')
    {
        cout<<s<<"es";
    }
    else cout<<s<<"s";
	return 0;
}


Measured memory_bytes: 3648
// atcoder/abc152/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    cout << (n == m ? "Yes" : "No") << endl;
  }

  return 0;
}


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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  cout << 15 - x1 - x2 - x3 - x4 - x5 << endl;
}

Measured memory_bytes: 3524
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  lll n,k;
  cin >> n >> k;
  vector<lll> h;
  h.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> h[ii];
  }
  lll num=0;
  for(ii=0;ii<n;ii++){
    if(h[ii] >=k){
      num++;
    }
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

letters = []
for i in range(N):
    if S[i] not in letters:
        letters.append(S[i])

ans = 0
for i in range(N):
    kinds = 0
    left = S[:i]
    right = S[i:]
    for j in range(len(letters)):
        if((letters[j] in left) and (letters[j] in right)):
            kinds = kinds + 1
    ans = max(kinds,ans)

print(ans)

Measured memory_bytes: 3064
n, z, w = map(int, input().split())
cards = list(map(int, input().split()))

if n == 1:
    print(abs(cards[0]-w))
    exit()

pattern1 = abs(cards[-1] - w)  # 初手で全部とる
pattern2 = abs(cards[-2] - cards[-1])  # それ以外

ans = max(pattern1, pattern2)
print(ans)

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

int main (void){
    int h,m,s;
    cin >> s;
    m = s/60;
    s = s - m*60;
    h = m/60;
    m = m - h*60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



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

int main() {
  int n,a = 0;
  cin >> n;
  for(int i = 1;i < n+1;i++){
    int c = 0;
    for(int j = 1;j < i+1;j++){
      if(i%j == 0){
        c++;
      }
    }
    if(c == 8 && i%2 == 1){
      a++;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> num;
int main()
{
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	ll a[n+1],pre[n+1];
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
	}
	pre[0] = 0ll;
	for(i=1;i<=n;++i)
	{
		pre[i] = pre[i-1] + a[i];
	}
	ll maxi = 0ll;
	for(i=1;i<=n;++i)
	{
		for(j=i;j<=n;++j)
		{
			num.push_back(pre[j]-pre[i-1]);
			maxi = max(maxi,pre[j]-pre[i-1]);
		}
	}
	vector<bool> yes(num.size(),true);
//	for(i=0;i<num.size();++i)
//	{
//		printf("%d ",num[i]);
//	}
//	printf("\n");
	int max_bit = 0;
	while(maxi>0)
	{
		max_bit++;
		maxi/=2;
	}
//	printf("%d\n",max_bit);
	ll ans = 0ll;
	vector<int> x;
	for(i=max_bit;i>=0;i--)
	{
		int cnt = 0;
		for(j=0;j<num.size();++j)
		{
			if(yes[j]==true)
			{
				if((num[j] & (1ll<<i)) != 0)
				{
			//		printf("%d %d\n",num[j],1ll<<i);
					++cnt;
				}
				else	x.push_back(j);
			}
		}
		if(cnt>=m)
		{
			ans = ans + (1ll<<i);
		//	printf("%d\n",i);
			for(j=0;j<x.size();++j)
			{
				yes[x[j]] = false;
			}
		}
		x.clear();
	}
	printf("%lld",ans);
}

Measured memory_bytes: 8428
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int v[2333][2333],e1[2333][2333],e2[2333][2333],n,m,q;
int query(int a[2333][2333],int x,int y,int xx,int yy){return a[xx][yy]+a[x-1][y-1]-a[x-1][yy]-a[xx][y-1];}
char s[2333][2333];
int main()
{
	get3(n,m,q);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)v[i][j]=s[i][j]-'0';
	}
	for(int i=1;i<=n;i++)for(int j=1;j<m;j++)e1[i][j]=v[i][j]&v[i][j+1];
	for(int i=1;i<n;i++)for(int j=1;j<=m;j++)e2[i][j]=v[i][j]&v[i+1][j];
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
	{
		v[i][j]+=v[i-1][j]+v[i][j-1]-v[i-1][j-1];
		e1[i][j]+=e1[i-1][j]+e1[i][j-1]-e1[i-1][j-1];
		e2[i][j]+=e2[i-1][j]+e2[i][j-1]-e2[i-1][j-1];
	}
	int x,y,xx,yy;
	while(q--)
	{
		get2(x,y);get2(xx,yy);
		printf("%d\n",query(v,x,y,xx,yy)-query(e1,x,y,xx,yy-1)-query(e2,x,y,xx-1,yy));
	}
	return 0;
}

Measured memory_bytes: 67328
#include <cstdio>
#include <algorithm>
const int maxn=100010,inf=100000000;
int b[maxn],ans;
int main()
{
	int n,h,k,a=-inf;
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;++i) 
		scanf("%d%d",&k,&b[i]),
		a=a>k?a:k;
	std::sort(b+1,b+1+n);
	for(int i=n;i>0;--i) 
	{
		if(a>=b[i]) 
		{
			int tmp=h/a;
			int yu=h%a;
			if(yu>0)ans++;
			ans+=tmp;
			h=0;
			break;
		}
		else 
			h-=b[i],
			ans++;
		if(h<=0) break;
	}
	if(h>0) {int tmp=h/a;int yu=h%a;if(yu>0) ans++; ans+=tmp;}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "algorithm"
#include "cstring"

using namespace std;
using ll = long long;
int n,x[16],y[16],d[16],D[16],p[16];
ll ans[16];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif



    memset(ans , 0x3f , sizeof(ans));
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&x[i],&y[i],&p[i]);
    }

    for(int i=0;i<n;i++){
        D[i] = min(abs(x[i]) , abs(y[i]));
    }
    ans[0] = 0;
    for(int i=0;i<n;i++){
        ans[0] += (ll)D[i]*p[i];
    }
    for(register int i=1;i<(1<<n);i++){
        int j = i;
        do{
            memcpy(d,D,sizeof(D));
            for(register int k=0;k<n;k++){
                if(i>>k&1){
                    if(j>>k&1){
                        for(register int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(x[q] - x[k]));
                        }
                    }
                    else{
                        for(register int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(y[q] - y[k]));
                        }
                    }
                }
            }
            ll tmp = 0;
            for(register int i=0;i<n;i++) tmp += (ll)d[i] * p[i];
            ans[__builtin_popcount(i)] = min(ans[__builtin_popcount(i)] , tmp);
            j = (j-1) & i;
        }while(j != i);
    }
    for(register int i=0;i<=n;i++) printf("%lld\n",ans[i]);
    return 0;
}









Measured memory_bytes: 3800
import java.util.*;

public class Main {

	// test 4  D
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();		// num of points
		int x = sc.nextInt();		// point X
		int y = sc.nextInt();		// point Y
		
		int ary_pathes[] = new int[n+1];

		// initialize array
		for (int i=1; i<=n; i++) {
			ary_pathes[i] = 0;
		}
		
		// node 1 からの loop
		for (int from=1; from<n; from++) {
			
			for(int to=from+1; to<=n; to++) {
				int len_normal;
				int len_skip;
				
				// 1: no skip
				len_normal = to-from;
				
				// 2: X-Y 通過
				len_skip=Math.abs(x-from) + 1 + Math.abs(to-y);
				
				if (len_skip < len_normal)
					ary_pathes[len_skip]++;
				else
					ary_pathes[len_normal]++;
			}
		}

		for (int i=1; i<n; i++) {
			log( ary_pathes[i]);
		}

		sc.close();
	}

	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

}


Measured memory_bytes: 23764
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    x = I()
    a = I()
    b = I()

    r = x - a
    while r >= b:
        r -= b
    print(r)
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
N = int(input())
D = {i: 1 for i in range(3, 55556, 2)}
D[2] = 1
for i in range(3, 237, 2):
  if D[i] == 1:
    for j in D:
      if j % i == 0 and j != i:
        D[j] = 0
L = []
for i in D:
  if D[i] == 1:
    L.append(i)
X = [[] for i in range(5)]
for i in L:
  X[i%5].append(i)
S = []
for i in range(N):
  S.append(X[1][i])
for i in range(N):
  if i != N - 1:
    print(S[i], end = ' ')
  else:
    print(S[i])

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF=2147483647;
int N,M;
map<int,set<int> >ET[100000];
struct Pq
{
	int _u,_c,_cost;
	Pq(){}
	Pq(const int u,const int c,const int cost):_u(u),_c(c),_cost(cost){}
};
bool operator<(const Pq &a,const Pq &b){return a._cost>b._cost;}
int Solve()
{
	static bool vis[100000];
	for(int i=0;i<N;i++)vis[i]=false;
	priority_queue<Pq>pq;
	for(const auto &p:ET[0])for(const int nxt:p.second)
	{
		pq.push(Pq(nxt,p.first,1));
	}
	int ans=INF;
	while(!pq.empty())
	{
		const Pq q=pq.top();pq.pop();
		if(q._u==N-1)
		{
			if(q._cost<ans)ans=q._cost;
		}
		if(!vis[q._u])
		{
			vis[q._u]=true;
			for(const auto &p:ET[q._u])for(const int nxt:p.second)
			{
				pq.push(Pq(nxt,p.first,q._cost+1));
			}
		}
		for(const int nxt:ET[q._u][q._c])
		{
			pq.push(Pq(nxt,q._c,q._cost));
		}
		ET[q._u][q._c].clear();
	}
//	assert(0);
	return ans==INF?-1:ans;
}
int main()
{
//	freopen("in.txt","r",stdin);
	while(scanf("%d%d",&N,&M)==2)
	{
		for(int i=0;i<N;i++)ET[i].clear();
		for(int i=0,a,b,c;i<M;i++)
		{
			scanf("%d%d%d",&a,&b,&c);
			--a,--b;
			ET[a][c].insert(b),ET[b][c].insert(a);
		}
		printf("%d\n",Solve());
	}
	return 0;
}

Measured memory_bytes: 65776
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	char x, y;
	cin >> x >> y;
	if (x < y) cout << "<" << endl;
	else if (x == y) cout << "=" << endl;
	else cout << ">" << endl;
}

Measured memory_bytes: 256
import itertools

N,M,Q = map(int,input().split())
arr = []
for _ in range(Q):
  arr.append(list(map(int,input().split())))

ans = 0

nums = range(1,M+1)
arrs = itertools.combinations_with_replacement(nums, N)

for a in arrs:
  _sum = 0
  a = list(a)
  for b in arr:
    if a[b[1]-1]-a[b[0]-1]==b[2]:
      _sum += b[3]
  ans = max(ans,_sum)
  
  
print(ans)
      

Measured memory_bytes: 9056
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = []
if len(p) == 0:
    print(X)
    exit()
for i in range(-1000, 1000):
    if not i in p:
        l.append(i)

ans_n = 1000
ans = 0
for i in range(-1000, 1000):
    if ans_n > abs(X-l[i]):
        ans_n = abs(X-l[i])
        ans = l[i]

print(ans)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<ll,pl> pp;
const ll MOD = 1e9+7;
const ll MAX = 1e18*2;

int main(){
  ll n,h[111111],dp[111111];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>h[i];
  fill_n(dp,111111,MAX);
  dp[0]=0;
  for(int i=0;i<n;i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1920
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val F = (1..n).map {
                readLine()!!.split(" ").map(String::toInt)
            }
    val P = (1..n).map { 
            readLine()!!.split(" ").map(String::toInt)
            }
    
    val ans= mutableListOf<Int>()
    (0..1).map { a1 -> (0..1).map { a2 -> (0..1)
    .map { a3 -> (0..1).map { a4 -> (0..1)
    .map { a5 -> (0..1).map { a6 -> (0..1)
    .map { a7 -> (0..1).map { a8 -> (0..1)
    .map { a9 -> (0..1).map { a10 -> 
    val bits = listOf(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
    if(bits.contains(1) == true){
        var score = F.mapIndexed{i,f->
            var and_sum = bits.zip(f).toList<Pair<Int,Int>>().map{
                        var (b1,b2) = it
                        b1*b2
                      }.sum()
            P[i][and_sum]
        }.sum()
        
        ans.add(score)
    }}}}}}}}}}}
    println(ans.max())
}

Measured memory_bytes: 69476
def is_gu(s):
    if s[0:len(s)//2] == s[len(s)//2:len(s)]:
        return True
    return False

S = input()
ans = len(S)-2

while True:
    if is_gu(S[0:ans]):
        break
    else:
        ans = ans-2

print(ans)

Measured memory_bytes: 61844
def main():
    platform_count = int(input())
    platforms = [int(x) for x in input().split()]

    dp = [0] * platform_count
    for i in range(platform_count):
        if i == 0:
            dp[i] = 0
        elif i == 1:
            dp[i] = abs(platforms[i] - platforms[i - 1])
        else:
            dp[i] = min(
                abs(platforms[i] - platforms[i - 1]) + dp[i - 1],
                abs(platforms[i] - platforms[i - 2]) + dp[i - 2])
    print(dp[platform_count - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 20476
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long n,i;
	cin>>n;
	long long a[n];
	bool c=true;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)
			c=false;
	}
	if(c)
		cout<<"APPROVED"<<endl;
	else
		cout<<"DENIED"<<endl;
	return 0;
}


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

int main(){
  char str[1200];
 
  while(fgets(str,1200,stdin)!=NULL){
    int pos = 0;
    vector<string> ans;

    while(1){
      string word;
      while(str[pos] != '.' && str[pos] != ' ' && str[pos] != ',' && str[pos] != '\n')word.push_back(str[pos++]);
      
      if(str[pos] == '\n')break;
      
      if( 2<(int)word.size() && (int)word.size()<7){
	/*
	bool f = true;
	for(int i=0;i<(int)word.size();i++){
	  if( (word[i] < 'a' || word[i] > 'z') && (word[i] < 'A' && word[i] > 'Z') ){
	    f = false;
	    break;
	    }
	  }
	*/
	/*if(f)*/ans.push_back(word);
	
      }
     
      pos++;
    }
    
    for(int i=0;i<(int)ans.size()-1;i++){
      cout << ans[i] << " ";
    }
    if((int)ans.size())cout << ans[(int)ans.size()-1] << endl;
    
  }
}

Measured memory_bytes: 0
n=int(input())
i=0
b=[]
q=n
ans=""

while 1:
  r=q%(-2)
  if q==0:
    b.append(0)
    break
 
  if r==0:
    b.append(0)
    q=int(q/(-2))
  else:
    b.append(1)
    q=int(q/(-2)+0.5)
    if q==0:
      break
  i=i+1

b.reverse()
for j in range(i+1):
  ans=ans+str(b[j])
  
print(ans)


Measured memory_bytes: 3064
import java.lang.Math.min

// Libraries
fun string(): String = readLine()!!
fun int(): Int = readLine()!!.toInt()
fun long(): Long = readLine()!!.toLong()
fun stringList(): List<String> = readLine()!!.split(" ")
fun intList(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun longList(): List<Long> = readLine()!!.split(" ").map(String::toLong)

// 最大公約数(ユーグリットの互除法)
tailrec fun gcd(a: Int, b: Int): Int = when {
    a < b -> gcd(b, a)
    b == 0 -> a
    else -> gcd(b, a % b)
}

fun main(args: Array<String>) {
    val (N, A, B) = longList()

    val res = N / (A + B) * A
    val c = N % (A + B)
    println(res + min(c, A))
}


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

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long ll;

int sgn(int x) {
	if (x < 0) {
		return -1;
	} else if (x > 0) {
		return 1;
	} else {
		return 0;
	}
}

bool sorter(const pair<int, int> &a, const pair<int, int> &b) {
	if (a.ff != b.ff) {
		return a < b;
	} else {
		if(a.ff % 2 == 0) {
			return a < b;
		} else {
			return b < a;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cerr.tie(0);
	
	int H, W; cin >> H >> W;
	//vector<vector<int> > g(H, vector<int>(W));
	
	vector<pair<int, int> > odds;
	
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			int a; cin >> a;
			if (a % 2 == 1) {
				odds.pb(mp(i, j));
			}
		}
	}
	sort(odds.begin(), odds.end(), sorter);
	vector<pair<pair<int, int>, pair<int, int> > > sol;
	for (int i=0; i<(int)odds.size()/2; i++) {
		auto &a = odds[2*i];
		auto &b = odds[2*i+1];
		while (a != b) {
			if (a.ff % 2 == 0) {
				if (a.ss == W-1) {
					sol.eb(a, mp(a.ff+1, W-1));
					a.ff+=1;
				} else {
					sol.eb(a, mp(a.ff, a.ss+1));
					a.ss+=1;
				}
			} else {
				if (a.ss == 0) {
					sol.eb(a, mp(a.ff+1, 0));
					a.ff+=1;
				} else {
					sol.eb(a, mp(a.ff, a.ss-1));
					a.ss-=1;
				}
			}
		}		
	}
	cout << sol.size() << "\n";
	for (auto &e : sol) {
		cout << e.ff.ff+1 << " " << e.ff.ss+1 << " " << e.ss.ff+1 << " " << e.ss.ss+1 << "\n";
	}
}


Measured memory_bytes: 6128
import os
import sys
from collections import Counter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

counts = Counter(A)
ma = max(A)
mi = min(A)
ok = True
if ma % 2 == 0:
    ok &= mi == ma // 2
    ok &= counts[mi] == 1
else:
    ok &= mi == ma // 2 + 1
    ok &= counts[mi] == 2
for d in range(ma, mi, -1):
    ok &= counts[d] >= 2
if ok:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3316
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int dg = 0;
    while(N!=0){
      N=N/K;
      dg=dg+1;
    }
    System.out.println(dg);
  }
  

  
}

Measured memory_bytes: 22996
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <cmath>

int main()
{
    int H, A;
    std::cin >> H;
    std::cin >> A;
    
    int x = std::ceil((double)H/A);
    
    std::cout << x << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    if (U == S) A--;
    else B--;
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())

buf = 0            #嬉しさポイント
m = 0               #残金

if n == 0:
    print("0")
    sys.exit()

def check(x,buf):
    if x >= 500:
        m = x%500
        buf += (x//500)*1000
        buf = check(m,buf)
        return buf
    elif 0 < x >= 5:
        buf += (x//5)*5
        return buf
    else:
        return buf

kei = check(n,buf)
print(kei)

Measured memory_bytes: 38256
<?php
fscanf(STDIN, "%d", $N);
$L = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($L);

$ans = 0;
for ($i = 0; $i < $N - 2; $i++) {
    for ($j = $i + 1; $j < $N - 1; $j++) {
        if ($L[$i] === $L[$j]) continue;
        for ($k = $j + 1; $k < $N; $k++) {
            // printf("%d %d %d\n", $i, $j, $k);
            if ($L[$j] === $L[$k]) continue;
            if ($L[$i] + $L[$j] <= $L[$k]) break;
            $ans++;
        }
    }
}
printf("%d", $ans);


Measured memory_bytes: 16084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  REP(i, c) cin >> r[i];
  RSORT(p);
  RSORT(q);
  p.resize(x);
  q.resize(y);
  p.reserve(p.size() + q.size() + r.size());
  copy(q.begin(), q.end(), back_inserter(p));
  copy(r.begin(), r.end(), back_inserter(p));
  RSORT(p);
  p.resize(x + y);
  ll ans = 0;
  REP(i, x + y) ans += p[i];
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	char a[510][510]={0},b[510][510]={0};
	rep(i,510)rep(j,510)a[i][j]=b[i][j]='.';
	vector<string>in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)rep(j,m)if(j==0||j!=m-1&&i%2)a[i][j]='#';
	rep(i,n)rep(j,m)if(j==m-1||j!=0&&i%2==0)b[i][j]='#';

	rep(i,n)rep(j,m)if(in[i][j]=='#'){
		if(i%2==0)a[i][j]='#';
		else b[i][j]='#';
	}

	rep(i,n){rep(j,m)cout<<a[i][j];cout<<endl;}
	cout<<endl;
	rep(i,n){rep(j,m)cout<<b[i][j];cout<<endl;}
}






Measured memory_bytes: 1664
def hahaha():
    n=int(input())
    count=1
    list=[]
    for i in range(0,n):
        list.append(str(input()))
    list.sort()
    a=list[0]
    for j in range(0,n):
        if a!=list[j]:
            a=list[j]
            count+=1
    print(count)
if __name__ == '__main__':
    hahaha()


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

int main()
{
	int n_person = 0;
	int a_newsp = 0;
	int b_newsp = 0;
    int both = 0;
    int min = 0;

	scanf("%d %d %d", &n_person, &a_newsp, &b_newsp);

	if (a_newsp > b_newsp) {
		both = b_newsp;
	} else {
		both = a_newsp;
	}

	min = (a_newsp + b_newsp) - n_person;
	if (min > 0) {
	} else {
		min = 0;
	}
	printf("%d %d", both, min);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,A=26;
  scanf("%d",&D);
  vector<int> C(A);
  for(int i=0;i<A;i++){
    scanf("%d",&C[i]);
  }
  vector<vector<int>> S(D,vector<int>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      scanf("%d",&S[i][j]);
    }
  }
  vector<int> X(A,0);
  vector<int> XX(A,0);
  vector<vector<pair<int,int>>> Q(D,vector<pair<int,int>>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      X[j]+=C[j];
      XX[j]+=X[j];
      Q[i][j]=make_pair(-S[i][j]-X[j],j);
    }
    sort(Q[i].begin(),Q[i].end());
    XX[Q[i][0].second]-=X[Q[i][0].second];
    X[Q[i][0].second]=0;
  }
  vector<vector<int>> P(D,vector<int>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      P[i][j]=Q[i][j].second;
    }
  }
  int SC=0,SC2;
  for(int i=0;i<D;i++){
    SC+=S[i][P[i][0]];
  }
  vector<int> Y;
  vector<int> YY;
  int Z;
  int SX,SY;
  int z=-1;
  for(int l=0;l<123;l++){
    for(int k=0;k<25;k++){
      while(k==z){
        k=rand()%25;
      }
      z=k;
      for(int i=0;i<D;i++){
        SC2=SC;
        YY=XX;
        Y=X;
        SC2-=S[i][P[i][0]];
        SC2+=S[i][P[i][k+1]];
        for(int j=0;j<A;j++){
          Y[j]=0;
        }
        YY[P[i][0]]=0;
        YY[P[i][k+1]]=0;
        for(int j=0;j<D;j++){
          if(i==j){
            Z=P[j][k+1];
          }else{
            Z=P[j][0];
          }
          Y[P[i][0]]+=C[P[i][0]];
          Y[P[i][k+1]]+=C[P[i][k+1]];
          Y[Z]=0;
          YY[P[i][0]]+=Y[P[i][0]];
          YY[P[i][k+1]]+=Y[P[i][k+1]];
        }
        SX=0;
        SY=0;
        for(int j=0;j<A;j++){
          SX+=XX[j];
          SY+=YY[j];
        }if(SC2-SY>SC-SX){
          P[i].insert(P[i].begin(),P[i][k+1]);
          P[i].erase(P[i].begin()+k+2,P[i].begin()+k+3);
          XX=YY;
          SC=SC2;
        }
      }
    }
  }
  /*
  int uku=0;
  for(int i=0;i<A;i++){
    X[i]=0;
  }
  for(int i=0;i<D;i++){
    uku+=S[i][P[i][0]];
    for(int j=0;j<A;j++){
      X[j]+=C[j];
    }
    X[P[i][0]]=0;
    SX=0;
    for(int i=0;i<A;i++){
      SX+=X[i];
    }
    uku-=SX;
  }
  cout<<uku<<endl;
  */
  for(int i=0;i<D;i++){
    cout<<P[i][0]+1<<"\n";
  }
}

Measured memory_bytes: 3884
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string s;
  cin >> s;
  vector<vector<ll> > dp(s.size()+1,vector<ll>(13,0));
  dp[0][0] = 1;
  rep(i,s.size()){
    int c = (s[i] == '?') ? -1 : s[i] - '0';
    if(c >= 0){
      rep(j,13) dp[i+1][(10*j + c) % 13] = dp[i][j];
    }
    else{
      rep(j,13)
        rep(k,10)
          dp[i+1][(10*j + k) % 13] = (dp[i+1][(10*j + k) % 13] + dp[i][j]) % MOD;
    }
  }
  cout << dp[s.size()][5] << endl;
}



Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> a(m), b(m), c(m);
    REP(i, 0, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i] = -(c[i] - p);
    }
    const ll inf = 1LL << 60;
    auto Cost = make_v(n, inf);
    Cost[0] = 0;
    ll ans = -inf;
    ll tmp = -inf;
    REP(i, 0, 5 * n) {
        REP(j, 0, m) {
            if (Cost[a[j]] == inf) continue;
            chmin(Cost[b[j]], Cost[a[j]] + c[j]);
            if (b[j] == n - 1) {
                dump(Cost[b[j]], i);
            }

            if (i < 3 * n && b[j] == n - 1) {
                chmax(ans, -Cost[n - 1]);
            } else if (i >= 3 * n && b[j] == n - 1) {
                chmax(tmp, -Cost[n - 1]);
            }
        }
    }
    dump(ans, tmp);
    if (ans < tmp) {
        cout << -1 << endl;
    } else {
        cout << max(ans, 0LL) << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int n, m;

bool judge(string a[], string b[], int i, int j){
	for (int x = 0; x < m; x++) {
		for (int y = 0; y < m; y++) {
			if (a[i+x][j+y]!=b[x][y]) {
				return false;
			}
		}
	}
	return true;
}

int main()
{

	cin >> n >> m;

	string a[n];
	string b[n];

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

	for (int i = 0; i < n-m+1; i++) {
		for (int j = 0; j < n-m+1; j++) {
			if (a[i][j]==b[0][0]) {
				if (judge(a,b,i,j)) {
					cout << "Yes" << "\n";
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

}


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

#include <vector> 

#include <functional>
using namespace std;

#define SIZE_OF_ARRAY(a) (sizeof(a) / sizeof(a[0]))

int main()
{
    int N;
    int *a;
    std::vector<int> data;

    cin >> N;

    a = new int[N];

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        data.push_back(a[i]);
	
    }
   
    std::sort(data.begin(),data.end());//昇順ソート

    cout << data[N-1] - data[0] << endl;

    return 0;
}


Measured memory_bytes: 3616