akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

string pat = "abcd";
int parse(string &s, int l, int r, string &p) {
    int paren = 0, pre = l+2, block = 0;
    if(s[l] == '[') {
        char op = s[l+1];
        int values[2] = {};
        for(int i=l+2; i<r; i++) {
            if(s[i] == '[') paren++;
            if(s[i] == ']') paren--;

            if(paren == 0) {
                values[block++] = parse(s, pre, i+1, p);
                pre = i+1;
            }
        }

        if(op == '+') {
            return values[0] | values[1];
        }
        if(op == '*') {
            return values[0] & values[1];
        }
        if(op == '^') {
            return values[0] ^ values[1];
        }
        assert(false);
    }
    else {
        assert(r - l == 1);
        return p[pat.find(s[l])] - '0';
    }
}
 
signed main() {
    string s;
    while(cin >> s, s != ".") {
        string pass; cin >> pass;
        int res = parse(s, 0, s.length(), pass);
        int cnt = 0;
        
        for(int i=0; i<10000; i++) {
            string p = "";
            int n = i;
            for(int k=0; k<4; k++) {
                p += (char)('0' + (n % 10));
                n /= 10;
            }

            int r = parse(s, 0, s.length(), p);
            if(res == r) cnt++;
        }

        printf("%lld %lld\n", res, cnt);
    }
    return 0;
}



Measured memory_bytes: 3344
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

string s[11];

int bit(int x, int y) {
  return (x >> y) & 1;
}

int main() {
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);
  rep(i,0,h) {
    cin >> s[i];
  }
  int ans = 0;
  rep(i,0,1<<h) {
    rep(j,0,1<<w) {
      int cnt = 0;
      rep(a,0,h) if(bit(i,a) == 0) {
        rep(b,0,w) if(bit(j,b) == 0) {
          cnt += s[a][b] == '#';
        }
      }
      ans += cnt == k;
    }
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 3768
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string o, e;
	cin >> o >> e;
	int size_o = SIZE(o);
	int size_e = SIZE(e);

	string ans = "";
	REP(i, min(size_o, size_e))
	{
		ans += o.substr(i, 1) + e.substr(i, 1);
	}
	if (size_o > size_e)
		ans += o.substr(size_o - 1, 1);

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int t[]= new int[n];
		int all=0;
		for(int i=0;i<n;i++) {
			t[i]=scan.nextInt();
			all+=t[i];
		}
		int m= scan.nextInt();
		int p[]= new int[m];
		int x[]= new int[m];
		for(int i=0;i<m;i++) {
			p[i]=scan.nextInt();
			x[i]=scan.nextInt();
		}
		scan.close();

		for(int i=0;i<m;i++) {
			int sum=all;
			for(int j=0;j<n;j++) {
				if( p[i]-1==j ) {
					sum += -t[ p[i]-1 ] + x[i] ;
					System.out.println(sum);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
#define N 2000

int solve(int,int);

int n;
int A[N];

int main(){
  int i;
  int q,m;

  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}

int solve(int i,int m){
  int res;

  if(m==0) return 1;
  else if(i>=n) return 0;

  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int dp[2010][2010];

int LCS(string s, string t) {
    rep(i, s.size() + 10) dp[i][0] = 0;
    rep(i, t.size() + 10) dp[0][i] = 0;

    for(int i = 1; i <= s.size(); i++) {
        for(int j = 1; j <= t.size(); j++) {
            dp[i][j] = 0;
            chmax(dp[i][j], dp[i - 1][j]);
            chmax(dp[i][j], dp[i][j - 1]);

            if(s[i - 1] == t[j - 1]) {
                chmax(dp[i][j], dp[i - 1][j - 1] + 1);
                //cout << "foo" << endl;
            }
        }
    }
    
    return dp[s.size()][t.size()];
}

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

    int q;
    cin >> q;
    rep(i, q) {
        string s, t;
        cin >> s >> t;
        cout << LCS(s, t) << endl;
    }
    return 0;
}



Measured memory_bytes: 15060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
double D[80]; int d;

double pop_n(){
  return (D[--d]);}
void push_n(double a) {
  D[d]=a; d++;
}

int main() {
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp != NULL) {
      double a,b;
      if ((tp[0] == '+') && (tp[1]==0)) {
        b = pop_n(); a = pop_n();
        push_n(a+b);
      }
      else if (tp[0] == '*') {
        b = pop_n(); a = pop_n();
        push_n(a*b);
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        b = pop_n(); a = pop_n();
        push_n(a-b);
      }
      else if (tp[0] == '/') {
        b = pop_n(); a = pop_n();
        push_n(a/b);
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",pop_n());
  }
  return 0;
}

Measured memory_bytes: 580
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
int main() {
	int i, j, D[6] = { 0 }, n;
	double d;
	fscanf(stdin, "%d", &n);
	for (i = 0; i < n; i++) {
		fscanf(stdin, "%lf", &d);
		if (d < 165.0) d = 160.0;
		else if (d >= 185.0) d = 185.0;
		D[(int)d/5 - 32]++;
	}
	for (i = 0; i < 6; i++, putchar('\n')) {
		fprintf(stdout, "%d:", i + 1);
			for (j = 0; j < D[i]; j++)
				putchar('*');
	}
	return 0;
}

Measured memory_bytes: 644
import math

n,D=map(int,input().split())
ps=[list(map(int, input().split())) for _ in range(n)]

res = 0
for i in range(0, n):
    for j in range(i + 1, n):
        d = 0
        for k in range(D):
            d += (ps[i][k] - ps[j][k]) * (ps[i][k] - ps[j][k])
        s = int(round(math.sqrt(d)))
        if s * s == d:
            res += 1
print(res)

Measured memory_bytes: 3064
/* a */
#include<stdio.h>
#include<math.h>
int main(void)
{
  int m,d,i,j,a,b,f;
  scanf("%d %d",&m,&d);
    a=0;
    for(i=1;i<10;i++){
      if(d>=10*i){
	a++;
      }}
  b=d-10*a;   
  /*  printf("%d\t%d\n",a,b);*/
  for(i=2;i<a;i++){
    for(j=2;j<=9;j++){
      if(i*j<=m){
	f++;
      }}}
  if(b>1){
    for(j=2;j<=b;j++){
      if(a*j<=m){
	f++;
      }}}
  printf("%d\n",f);
    return 0;
}


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

int main()
{
    int a;
    int b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    } else if (b < a) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include<stdio.h>
int main()
{
	int team[101][3]={0},suu,kazu[101]={0},l1,l2,sum[101]={0},sum1=0,zyui[101]={0},kai=1;
	scanf("%d",&suu);
	sum1=suu*(suu-1)/2;
	for(int i=1;i<sum1+1;i++){
		scanf("%d %d",&l1,&l2);
		scanf("%d %d",&kazu[l1],&kazu[l2]);
		if(kazu[l1]==kazu[l2]){
			team[l1][2]+=1;
			team[l2][2]+=1;
		}
		else if(kazu[l1]>kazu[l2]){
			team[l1][0]+=1;
			team[l2][1]+=1;
		}
		else if(kazu[l2]>kazu[l1]){
			team[l2][0]+=1;
			team[l1][1]+=1;
		}
	}
	for(int i=1;i<suu+1;i++){
		sum[i]=team[i][0]*3+team[i][2];
	}
	for(int i=1;i<suu+1;i++){
		for(int i1=1;i1<suu+1;i1++){
			if(i!=i1){
				if(sum[i]<sum[i1]){
					zyui[i]++;
				}
			}
		}
	}
	for(int i=1;i<suu+1;i++){
		printf("%d\n",zyui[i]+1);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=1 && a<=3 && b>=1 && b<=3 && a!=b)
    {
        if(a==3)
            printf("%d\n",a-b);
        else if(b==3)
            printf("%d\n",b-a);
        else
            printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int R = sc.nextInt();
        int S = sc.nextInt();
        int P = sc.nextInt();
        String T =sc.next();;
        char[] ct=T.toCharArray();
        long ans=0;
        boolean[] flg= new boolean[N];
        for(int i=0;i<N;i++)flg[i]=false;
        char pre=' ';
        boolean preflg;
        for(int i=0;i<N;i++) {
        	if(i<K) {
        		pre='k';
        		preflg=false;
        	} else {
        		pre = ct[i-K];
        		preflg=flg[i-K];
        	}
        	if(ct[i]==pre) {
        		if(preflg==false) {
        			flg[i]=true;        			
        		} else {
        			ans = ans + kekka(ct[i],R,S,P);
        		}
        	} else {
    			ans = ans + kekka(ct[i],R,S,P);
        	}
        }
        
        
        
        
        System.out.println(ans);
        		
    }
    
    public static int kekka(char a,int R, int S, int P) {
    	if(a=='r') {
    		return P;
    	} else if(a=='s') {
    		return R;
    	} else {
    		return S;
    	}
    }
}

Measured memory_bytes: 26860
while 1:
	(n,x) = map(int,raw_input().split())
	if n == 0 and x == 0:
		break
	ans = 0
	for i in range(1,n+1):
		for j in range(i+1,n+1):
			for k in range(j+1,n+1):
				if i+j+k == x:
					ans += 1
	print ans

Measured memory_bytes: 4208
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N = 100100 , L = 17;
int n , dep[N] ;
ll ans[N];
vector<int>adj[N];
map<ii,ll>cost;

void dfs(int u,int par)
{
    dep[u]=1+dep[par];
    ans[u]=ans[par]+cost[{u,par}];

    for(auto v:adj[u])
        if( v!=par ) dfs(v,u);
}

int main()
{
    int n; scanf("%d",&n);
    for(int i=1; i<n; i++) // n-1 edges
    {
        int a , b , c;
        scanf("%d%d%d",&a,&b,&c);
        adj[a].push_back(b);
        adj[b].push_back(a);

        cost[{a,b}]=c;
        cost[{b,a}]=c;
    }

    int q,k; scanf("%d%d",&q,&k);
    cost[{k,0}]=0;
    dfs(k,0);

    while(q--){
        int a,b; scanf("%d%d",&a,&b);
        printf("%lld\n",ans[a]+ans[b]);
    }


    return 0;
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
 
using namespace std;    
  
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define mp make_pair
#define all(x) x.begin(), x.end()
#define ll long long
#define ull unsigned long long
#define sz(x) (int)x.size()
/*
string lower(string a) {
    for(int i=0;i<a.size();i++) {
        a[i]=tolower(a[i]);
    }
    return a;
}
ll nod(ll a,ll b) {
    if(a==0)
        return b;
    else if(b==0)
        return a;
    if(a>=b)
        return nod(a%b,b);
    else if(a<=b)
        return nod(a,b%a);
}
ll nok(ll x, ll y) {
    return x/nod(x,y)*y;
} 
*/
const ll INF = 1e9+7;
int main() {
//  freopen("measurement.in", "r", stdin);
//  freopen("measurement.out", "w", stdout);
    IOS	
    ll n;
    
    bool ok = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
    	ll x;
    	cin >> x;
    	if(x % 2 == 0 && x % 3 != 0 && x %5 !=0) {
    		cout << "DENIED" << endl;
    		ok = 1;
    		break;
		}
	}
	if(ok == 0) {
		cout << "APPROVED" << endl;
	}
	return 0;
} 	 

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

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

using namespace std;

typedef long long ll;

struct Data {
  int cur,weight;
  string state;
  bool operator < ( const Data &data ) const {
    if( weight != data.weight ) return weight > data.weight;
    if( state != data.state ) return state > data.state;
    return cur > data.cur;
  }
};

int ch,cw;
string start,goal;
unordered_map<string,int> mini;

int _move[9][4] = 
  {
    {6,1,3,8}, // A
    {7,2,4,0}, // B
    {8,3,5,1}, // C
    {0,4,6,2}, // D
    {1,5,7,3}, // E
    {2,6,8,4}, // F
    {3,7,0,5}, // G
    {4,8,1,6}, // H
    {5,0,2,7}  // I
  };

void compute(){
  mini.clear();
  priority_queue<Data> Q;
  {
    Data init;
    init.weight = 0;
    init.state = start;
    rep(i,9) if( start[i] == '0' ) { init.cur = i; break; }
    Q.push(init);
    mini[start] = 0;
  }
  while(!Q.empty()){
    Data data = Q.top(); Q.pop();
    if( data.state == goal ) { cout << data.weight << endl; return; }

    Data ndata = data;
    rep(i,4){
      int next = _move[ndata.cur][i];
      swap(ndata.state[ndata.cur],ndata.state[next]);
      int ncost = ndata.weight + ((i&1)?cw:ch);
      if( !mini.count(ndata.state) || mini[ndata.state] > ncost ) {
        mini[ndata.state] = ncost;
        ndata.cur = next;
        ndata.weight = ncost;
        Q.push(ndata);
        ndata.cur = data.cur;
        ndata.weight = data.weight;
      }
      swap(ndata.state[ndata.cur],ndata.state[next]);
    }
  }
}

int main(){
  while( cin >> cw >> ch, ch|cw ){
    start.clear(), goal.clear();
    rep(i,3) rep(j,3) {
      int tmp;
      cin >> tmp;
      start += string(1,(char)(tmp+'0'));
    }
    rep(i,3) rep(j,3) {
      int tmp;
      cin >> tmp;
      goal += string(1,(char)(tmp+'0'));
    }
    compute();
  }
  return 0;
}

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

int main(){
  int n,d,cnt=0;
  cin >> n >> d;
  for(int i=0;i<n;i++){
    long double p,q;
    cin >> p >> q;
    p = abs(p); q=abs(q);
    long double sum = (p*p+q*q);
    if(sqrtl(sum) <= d)cnt++;
    //cout << sqrtl(sum) << '\n';
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static class Reader {
		BufferedReader br;
		StringTokenizer st;
 
		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
	public static void main(String[] args) {
		Reader r = new Reader();
		
		int n = r.nextInt();
		int k = r.nextInt();
		int[] a = new int[n];
		int[] dp = new int[n];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		for (int i = 0; i < n; i++) {
			a[i] = r.nextInt();
		}
		
		dp[0] = 0;
		for (int i = 1; i < n; i++) {
			int min = Integer.MAX_VALUE;
			
			for (int j = 1; j <= k; j++) {
				if (i - j > -1) {
					min = Integer.min(min, dp[i - j] + Math.abs(a[i] - a[i - j]));
				} else {
					break;
				}
			}
			dp[i] = min;
		}
		System.out.println(dp[n - 1]);
	}
}


Measured memory_bytes: 32632
using System;

class AOJ {
  static void Main(string[] args)
  {
    string[] s;
    double x = 0, y = 0;
    int d, a, angle = 90;

    while (true) {
      s = Console.ReadLine().Split(',');

      d = int.Parse(s[0]);
      a = int.Parse(s[1]);

      if (d == 0 && a == 0)
        break;

      x += Math.Cos(angle * Math.PI / 180.0) * d;
      y += Math.Sin(angle * Math.PI / 180.0) * d;

      angle -= a;
    }
    Console.WriteLine("{0}\n{1}", (int)x, (int)y);
  }
}

Measured memory_bytes: 9136
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll mod = 1000000007;
int main(){
  int N;
  cin >> N;
  string S[N];
  for(int i=0;i<N;i++){
    cin >> S[i];
  }
  sort(S, S+N);

  int ans = 1;
  for(int i=1;i<N;i++){
    if(S[i]!=S[i-1]) ans++;
  }
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 9852
import math

MAX=1000000
MOD=1000000007

fac=[1,1]
finv=[1,1]
inv=[1,1]

for i in range(2,MAX):
	fac.append(fac[i-1] * i % MOD)
	inv.append(MOD - inv[ MOD % i ] * (int(MOD / i)) % MOD)
	finv.append(finv[i - 1] * inv[i] % MOD)

def COM(nnn, kkk):
	if nnn < kkk:
		return 0
	
	if nnn < 0 or kkk < 0:
		return 0
	
	return fac[nnn] * (finv[kkk] * finv[nnn-kkk] % MOD) % MOD


x,y = map(int, input().split())

n = 2 * x - y
m = 2 * y - x

ans = 0
if n % 3 == 0:
	if m % 3 == 0:
		nn = int(n / 3)
		mm= int(m / 3)
		ans = COM(nn+mm,nn)

print(ans)


Measured memory_bytes: 121836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N);
    for(auto& in:A) cin >> in;
    
    ll sum = accumulate(A.begin(),A.end(),0LL);
    
    ll half = sum/2;
    
    ll now = 0;
    
    res = LINF;
    for(int i = 0; i < N-1;i++){
        now += A[i];
        
        res = min(res,abs(now-(sum-now)));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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


int main() {
string x,y;cin>>x>>y;
int a,b;cin>>a>>b;
string z;cin>>z;
if(x==z)cout<<a-1<<' '<<b;
else cout<<a<<' '<<b-1;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
import os
from math import*

n=int(input())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))

ans=0
for i in range(n):
	if arr[i]>=brr[i]:
		ans+=brr[i]
	else:
		if arr[i]+arr[i+1]>=brr[i]:
			ans+=brr[i]
			arr[i+1]=arr[i]+arr[i+1]-brr[i]
		else:
			ans+=arr[i]+arr[i+1]
			arr[i+1]=0
print(ans)

Measured memory_bytes: 98728
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    REP(i,3){
        if(n[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    long long k,a,b; cin >> k >> a >> b;
    if(b-a<=2){
        cout << k+1 << endl;
        return 0;
    }
    k-=a-1;
    if(k%2==0){
        cout << a+(b-a)*k/2 << endl;
    }else{
        cout << a+1+(b-a)*(k-1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long gcdd(long long a,long long b){
  long long p=a;
  long long q=b;
  long long c=0;
  c = a%b;
  while(c != 0){
    p=q;
    q=c;
    c=p%q;
    //printf("%lld/",c);
  }
  return q;
}
  
int main(){
  long long a;
  long long b;
  long long c;
  long long d;
  long long upcnt=0;
  long long downcnt =0;
  long long cnt = 0;
  long long gcd = 0;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  gcd = gcdd(c,d);
  //printf("%lld/",gcd);
  upcnt = b - b/c - b/d + b/(c*d/gcd);
  downcnt = a - a/c - a/d + a/(c*d/gcd);
  cnt = upcnt - downcnt;
  if(a % c != 0 && a % d != 0){
    cnt++;
    //printf("H");
  }
  printf("%lld",cnt);
  return 0;
}
  

Measured memory_bytes: 128
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

f("Sunny", "Cloudy").
f("Cloudy", "Rainy").
f("Rainy", "Sunny").

main:-
    get_string(S),
    f(S, T),
    writeln(T).


Measured memory_bytes: 7988
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int count;

void merge (int A[], int n, int left, int mid, int right) {
    int n1, n2;
    int i, j, k;

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

    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;

    i = 0, j = 0;

    for (k = left; k < right; k++) {
        count++;
        if (L[i] <= R[j]){
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }    
    }
}

void mergeSort (int A[], int n, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main () {
    int n, i, A[MAX];
    count = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++) scanf("%d",&A[i]);

    mergeSort(A, n, 0, n);

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

    return 0;
}


Measured memory_bytes: 5632
import java.util.*;

public class Main{
		
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int n=input.nextInt();
		int m=input.nextInt();
		String a[]=new String[n];
		for(int i=0;i<n;i++)
			a[i]=input.next();
		Arrays.sort(a);
		for(int i=0;i<n;i++)
			System.out.print(a[i]);
	}
}

Measured memory_bytes: 23760
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=1e6+5,mod=1000000007;
int n,a[N],b[N];
int main()
{
	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<n&&cin>>a[i];i++) b[a[i]]++;
	for(int i=1;i<=n;i++) cout<<b[i]<<sl;
	return 0;
}


Measured memory_bytes: 5220
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64,
    }
    let ans = if (b - a) % 2 == 0 {
        (b - a) / 2
    }else{
        let c = min(a, n - b + 1);
        c + (b - a - 1) / 2
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
int H,W;

while(1){
scanf("%d %d",&H,&W);

if(H==0 && W==0)break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){    
if(i==0 || i==H-1 || j==0 || j==W-1){
printf("#");}else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2020
def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    H = min(H, Q*2)
    S = min(S, H*2)
    D = min(D, S*2)
    ans = N // 2 * D + (N%2) * S
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N;
  cin >> N;
  vector<int> b(N);
  rep(i, N) {
    cin >> b[i];
    b[i]--;
  }

  vector<int> result;
  rep(i, N) {
    int idx = -1;
    rrep(j, b.size()) {
      if (b[j] == j) {
        idx = j;
        break;
      }
    }
    if (idx < 0) {
      cout << -1 << endl;
      return 0;
    }
    b.erase(b.begin() + idx);
    result.push_back(idx);
  }

  rrep(i, N) { cout << result[i] + 1 << "\n"; }

  return 0;
}

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

ans = 0
b = 0
a = 0
ab = 0
for j in range(n):
     s = list(input())
     for i in range(len(s)-1):
          if s[i] == "A" and s[i+1] == "B":
               ans += 1
     if s[0] == "B":
          b += 1
          if s[-1] == "A":
               ab += 1
     if s[-1] == "A":
          a += 1

a -= ab
b -= ab

ans += max(ab-1,0)
if ab > 0:
     if a > 0:
          ans += 1
          a -= 1
     if b > 0:
          ans += 1
          b -= 1
ans += min(a,b)
print(ans)

Measured memory_bytes: 50408
#include <cstdio>
#include <algorithm>
int N, K, a[100001], G, M;
int gcd(int x, int y)
{
	int r;
	while (y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	G = M = a[1];
	for (int i = 2; i <= N; i++)
	{
		G = gcd(G, a[i]);
		M = std::max(M, a[i]);
	}
	puts(K <= M && K % G == 0 ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) {
      res=res*x%m;
    }
    return res;
}

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int> chars(26,0);
  REP(i,0,N){
    int c=(int) S.at(i)-'a';
    chars[c]++;
  }
  int ans=1;
  REP(i,0,26){
    if(chars[i]==0)continue;
    ans*=chars[i]+1;
    ans%=MOD;
  }
  print(ans-1);


}


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

ll dp[8000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,t;
    cin>>n>>t;
    t--;
    array<ll,2> a[n];
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a[i] = {x,y};
    }
    sort(a,a+n);
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=t+a[i][0];j>=a[i][0];j--){
            dp[j] = max(dp[j],dp[j-a[i][0]]+a[i][1]);
            ans = max(ans,dp[j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a>9 || b>9){
            System.out.println(-1);
        }else{
            System.out.println(a*b);
        }




        sc.close();
    }
}


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

int main()
{
    int n, m, l, k;
    cin >> n;
    m = n % 10;
    l = n % 100 - m;
    k = n - l - m;
    if (k == 700 || l == 70 || m == 7)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
N = int(input())
A = 0
for i in range(N):
	S = input()
	if S == "A":
		A += 1
		if i == N-1 or 2*A < i:
			print("NO")
			exit()

if N%2 == 1 or 2*A != N:
	print("NO")
else:
	print("YES")


Measured memory_bytes: 5592
#include<stdio.h>
#include <limits.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ull   = unsigned long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)



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


  int n;
  ll k;
  scan(n>>k);

  vint A(n);
  REP(i, n) scan(A[i]);

  vll cnt_front(n);
  REP(m, n){
    REP(i, m){
      if(A[m]<A[i]) cnt_front[m]++;
    }
  }

  vll cnt_back(n);
  REP(m, n){
    FOR(i, m, n){
      if(A[m]<A[i]) cnt_back[m]++;
    }
  }

  ull ans=0;
  REP(i, n){
    ans += (cnt_front[i]*((k*(k+1)/2)%MOD))%MOD + (cnt_back[i]*((k*(k-1)/2)%MOD))%MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "1 2", "3 1", "3" ].parse.expand.solve == "YES" );
	assert( [ "1 2", "3 2", "3" ].parse.expand.solve == "NO" );
	assert( [ "1 2", "3 3", "3" ].parse.expand.solve == "NO" );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto av = input.front.split.to!( long[] );
	input.popFront;
	auto bw = input.front.split.to!( long[] );
	input.popFront;
	auto t = input.front.to!( long );
	return tuple( av[ 0 ], av[ 1 ], bw[ 0 ], bw[ 1 ], t );
}

auto solve( long a, long v, long b, long w, long t )
{
	return ( abs( a - b ) - ( v - w ) * t <= 0 ) ? "YES" : "NO";
}


Measured memory_bytes: 2736
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S, T := sc.nextRuneSlice(), sc.nextRuneSlice()
	aSet := make(map[rune]int)
	for i, r := range S {
		aSet[r] = aSet[r]*10 + i
	}
	bSet := make(map[rune]int)
	for i, r := range T {
		bSet[r] = bSet[r]*10 + i
	}
	ok := true
	for i := 0; i < len(S); i++ {
		if aSet[S[i]] != bSet[T[i]] {
			ok = false
			break
		}
	}

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
import heapq
import math

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A = sorted(A)
num = 0
bef = None
count = 0
for a in A:
    if bef is None:
        bef = a
    if bef == a:
        count += 1
    else:
        if count % 2 == 1:
            num += 1
        count = 1
    bef = a
if count % 2 == 1:
    num += 1

print(num)


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

int main(){
    int n;
    string str;
    cin >> n;
    cin >> str;
    int sum = 0;
    int ans = 0;
    bool flag = false;
    for(int i=0;i<n-1;i++){
        for(char c='a';c<='z';c++){
            for(int j=0;j<=i;j++){
                for(int k=n-1;k>i;k--){
                    if(str[j]==c && str[k]==c){
                        flag = true;
                    }
                }
            }
            if(flag == true){
                sum++;
            }
            flag = false;
        }
        if(sum >= ans){
            ans = sum;
        }
        sum = 0;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define lint long long

const lint mod = 1E9 + 7;


int main(){
    string S;
    cin >> S;
    
    lint dp[S.length() + 1][4];
    int cnt = 0;
    for(int i = 0; i < S.length(); ++i){
        if(S[i] == '?'){
            cnt++;
        }
    }
    
    dp[0][0] = 1;
    dp[0][1] = dp[0][2] = dp[0][3] = 0;
    
    for(int i = 0; i < S.length(); ++i){
        for(int j = 0; j < 4; ++j){
            dp[i + 1][j] = dp[i][j];
        }
        if(S[i] == 'A'){
            dp[i + 1][1] = dp[i][1] + dp[i + 1][0];
        }
        if(S[i] == 'B'){
            dp[i + 1][2] = dp[i][2] + dp[i][1];
        }
        if(S[i] == 'C'){
            dp[i + 1][3] = dp[i][3] + dp[i][2];
        }
        if(S[i] == '?'){
            for(int j = 3; j >= 1; --j){
                dp[i + 1][j] = 3 * dp[i][j] + dp[i][j - 1];
            }
            dp[i + 1][0] = 3 * dp[i][0];
        }
        for(int j = 0; j < 4; ++j){
            dp[i + 1][j] %= mod;
        }
//        cout << dp[i + 1][0] << " " << dp[i + 1][1] << " " << dp[i + 1][2] << " " << dp[i + 1][3] << endl;
    }
    cout << dp[S.length()][3] << endl;
        
        
}


Measured memory_bytes: 3584
n,m = [int(s) for s in input().split(' ')]

ans = []
minn = 10000000
maxx = 0
for i in range(m):
    l,r = [int(s) for s in input().split(' ')]
    maxx = max(maxx,l)
    minn = min(minn,r)
if minn - maxx < 0:
    print(0)
else:
    print(minn - maxx+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define ld long double
#define pb push_back
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf ;
#define printf ;
using namespace std;
void i_love_misaka_mikoto();
int32_t main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
        freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<" セクンド\n";
    #endif
    return 0;
}

int sp[1001][1001];
int mod=1e9+7;
void i_love_misaka_mikoto(){
    int h, w;
    cin>>h>>w;
    sp[1][1]=1;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
            char c;
            cin>>c;
            if(c=='#'){
                sp[i][j]=-1;
                continue;
            }
            if(sp[i-1][j]!=-1)sp[i][j]+=sp[i-1][j];
            if(sp[i][j-1]!=-1)sp[i][j]=(sp[i][j]+sp[i][j-1])%mod;
        }
    cout<<sp[h][w];
}

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

int main() {
 string str; 
  int n,x,t,a,ans,i;
	cin >>  str;
	n=str.size();

	  vector<int> vec(10);
  for (i = 0; i < 10; i++) {
    vec.at(i)=0;
	}

for (i = 0; i < n; i++) {
	if(str.at(i)=='0'){
		vec.at(0)=vec.at(0)+1;
	}
	if(str.at(i)=='1'){
		vec.at(1)=vec.at(1)+1;
	}
	if(str.at(i)=='2'){
		vec.at(2)=vec.at(2)+1;
	}
	if(str.at(i)=='3'){
		vec.at(3)=vec.at(3)+1;
	}
	if(str.at(i)=='4'){
		vec.at(4)=vec.at(4)+1;
	}
	if(str.at(i)=='5'){
		vec.at(5)=vec.at(5)+1;
	}
	if(str.at(i)=='6'){
		vec.at(6)=vec.at(6)+1;
	}
	if(str.at(i)=='7'){
		vec.at(7)=vec.at(7)+1;
	}
	if(str.at(i)=='8'){
		vec.at(8)=vec.at(8)+1;
	}
	if(str.at(i)=='9'){
		vec.at(9)=vec.at(9)+1;
	}	
}
	ans=0;
  for (i = 0; i < 10; i++) {
    ans=ans+vec.at(i)*i;
	}
	a=ans%9;
	if(a==0){	
	cout << "Yes" << endl;
	}
	else{
	cout << "No"<< endl;
	}
	

}




Measured memory_bytes: 3728