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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N%2==1)cout << "No" << endl;
    else{
    int i;
    int flag = 0; 
    for(i=0;i<N/2;i++)if(S[i]!=S[i+N/2])flag++;
    if(flag>0)cout << "No" << endl;
    else{cout << "Yes" << endl;}
    }
}

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

const int N = 200010;
const int mod = 1e9 + 7;

typedef long long LL;

char s[N];

int f[N], g[N], dp[2][2][N];

int main() {
    int n, m; scanf("%d%d%s", &n, &m, s + 1);
    bool flag = false;
    for (int i = 1; i <= m; i++) if (s[i] != s[1]) {
        flag = true; break;
    } 
    if (flag) {
        if (n & 1) return puts("0"), 0;
        int fir = 0;
        for (int i = 1; i <= m; i++) if (s[i] != s[1]) {
            fir = i - 1; break;
        }
        int lim = fir | 1;
        for (int i = fir + 1; i <= m; i++) if (s[i] != s[1]) {
            int j = i + 1;
            while (j <= m && s[j] == s[1]) j++;
            if (j <= m && (j - i - 1) % 2 == 1) lim = min(lim, j - i - 1); 
        } 
        n /= 2, lim = (lim + 1) / 2;
        for (int i = 1; i <= lim; i++) f[i] = i * 2;
        for (int i = 1, diff = 0; i <= n; i++) {
            diff = (diff + g[i]) % mod, f[i] = (f[i] + diff) % mod;
            if (i + 1 <= n) g[i + 1] = (g[i + 1] + f[i]) % mod;
            if (i + lim + 1 <= n) g[i + lim + 1] = (g[i + lim + 1] - f[i] + mod) % mod;
        }
        printf("%d\n", f[n]);
    } else {
        dp[1][1][1] = dp[0][0][1] = 1;
        for (int i = 2; i <= n; i++) 
            for (int t = 0; t <= 1; t++) {
                dp[t][0][i] = (dp[t][1][i - 1] + dp[t][0][i - 1]) % mod;
                dp[t][1][i] = dp[t][0][i - 1];
            }
        printf("%d\n", ((LL)dp[1][0][n] + dp[0][0][n] + dp[0][1][n]) % mod);
    }
    return 0;
}//

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const int di[4] = { 1,0,-1,0 };
const int dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n,ans;
int cnt[110];

void input(){
	cin>>n;
	return;
}

void solve(){
	for(int i=2;i<=n;i++){
		int j=i;
		for(int k=2;k<=n;k++){
			while(j%k==0){
				cnt[k]++;
				j/=k;
			}
		}
	}
	for(int i=2;i<=n;i++){
		if(cnt[i]>73)ans++;
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(cnt[i]>1&&cnt[j]>23)ans++;
			if(cnt[j]>1&&cnt[i]>23)ans++;
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(cnt[j]>3&&cnt[i]>13)ans++;
			if(cnt[i]>3&&cnt[j]>13)ans++;
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if(cnt[i]>1&&cnt[j]>3&&cnt[k]>3)ans++;
				if(cnt[j]>1&&cnt[i]>3&&cnt[k]>3)ans++;
				if(cnt[k]>1&&cnt[i]>3&&cnt[j]>3)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll x;
	cin>>x;
	if(x<600)
		cout<<8;
	else if(x<800)
		cout<<7;
	else if(x<1000)
		cout<<6;
	else if(x<1200)
		cout<<5;
	else if(x<1400)
		cout<<4;
	else if(x<1600)
		cout<<3;
	else if(x<1800)
		cout<<2;
	else
		cout<<1;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<":\n";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>

char str[100000 + 100];
int main() {
    int n, a, b;
    while (scanf("%d%d%d", &n, &a, &b) != EOF) {
        scanf("%s", str);
        int len = strlen(str);
        int a_cnt = 0;
        int b_cnt = 0;
        for (int i = 0; i < len; i++) {
            bool isYes = false;
            if (str[i] == 'a') {
                if (a_cnt + b_cnt < a + b) {
                    a_cnt++;
                    isYes = true;
                }
            }
            if (str[i] == 'b') {
                if (a_cnt + b_cnt < a + b) {
                    if (b_cnt < b) {
                        b_cnt++;
                        isYes = true;
                    }
                }
            }
            puts(isYes?"Yes":"No");
        }
    }
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define MOD (1000000007);
#define INF (2e9)



int main(void){
	ll x;
	cin>>x;
	ll ans=0;
	ans+=x/11*2;
	if(x%11>0){
		if(x%11<=6){
			ans++;
		}else{
			ans++;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int h;
  int w;
  int k;
  cin >> h >> w >> k;
  char mark[h][w];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> mark[i][j];
    }
  }
  int ans=0;
  for(int bith=0; bith<(1 << h); bith++){
    for(int bitw=0; bitw<(1 << w); bitw++){
      int black=0;
      for(int i=0; i<h; i++){
	for(int j=0; j<w; j++){
	  if(!(bith & (1 << i)) && !(bitw & (1 << j))){
	  if(mark[i][j] == '#')black++;
	  }
	}
      }
      if(black == k)ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    int count=1;
    int ans=0;
    for(int i=0; i<n; i++){
        if(a.at(i) == count){
            count++;
        }
        else{
            ans++;
        }
    }
    if(ans == n) cout << "-1"<< endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3984
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <climits>
#include <bitset>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
#include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef pair<int,long long> pil;
typedef pair<long long,int> pli;
typedef vector<vector<long long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef priority_queue<int, vector<int>, greater<int> > minq;
typedef priority_queue<int> maxq;
// to initialize PQs with a vector, do 
// minq(v.begin(),v.end()) or maxq(v.begin(),v.end())
// or minq(a,a+10) for arrays

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    ll n; int m;
    cin>>n>>m;
    ll daysneeded=0;
    for (int i = 0; i<m; ++i) {
        ll x; cin>>x;
        daysneeded += x;
    }

    if (daysneeded>n) {
        cout<<-1;
    } else {
        cout<<n-daysneeded;
    } cout<<el;



}

Measured memory_bytes: 3644
#include<stdio.h>

int main(void){

    int A,B,ans = -1,i;

    scanf("%d %d",&A,&B);

    for(i = 0;i <= 10000;i++){
        if((int)(i*0.08) == A && (int)(i*0.1) == B){
            ans = i;
            break;
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static final int mod = (int) (1e9)+7;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] a= new int[4];
		String[] as = {"AC", "WA", "TLE", "RE"};
		while(n-->0) {
			String verdict = sc.nextLine();
			switch(verdict) {
				case "AC":
					a[0]++;
					break;
				case "WA":
					a[1]++;
					break;
				case "TLE":
					a[2]++;
					break;
				default:
					a[3]++;
			}			
		}
		for (int i = 0; i < 4; i++) {
			out.printf("%s x %d\n", as[i], a[i]);
		}
		out.close();
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}

Measured memory_bytes: 42800
R, C, K = map(int, input().split())
item = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    item[r][c] = v


dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)]

for i in range(R+1):
    for j in range(C+1):
        for k in range(4):
            here = dp[k][i][j]
            # 次の"行"に移動する場合（下に移動するので今まで獲得したアイテムの個数はリセットされる）
            if i + 1 <= R:
                # 移動先のアイテムを取らない場合
                dp[0][i+1][j] = max(dp[0][i+1][j], here)
                # 移動先のアイテムをとる場合
                dp[1][i+1][j] = max(dp[1][i+1][j], here+item[i+1][j])
            # 次の列に移動する場合（右に移動するのでその行で獲得したアイテムの個数は維持される）
            if j + 1 <= C:
                dp[k][i][j+1] = max(dp[k][i][j+1], here)
                # 現在のkが3未満のときのみ，移動先のアイテムをとることが可能
                if k < 3:
                    dp[k+1][i][j+1] = max(dp[k+1][i][j+1], here+item[i][j+1])

ans = 0
for k in range(4):
    ans = max(ans, dp[k][-1][-1])
print(ans)


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

int main(){
    int a,b,k,n=0;
    cin >> a >> b >> k;
    vector<int> div;
    for(int i = 1; i < 101; ++i){
        if(a%i == 0 && b%i == 0)
            div.push_back(i);
    }
    cout << div[div.size()-k] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int n = sca.nextInt();
	int k = sca.nextInt();
	int ans = 1;
	while(n/k != 0) {
		n = n / k;
		ans++;
	}

	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  N = S.size();
  int b = 1<<(N-1);
  long long m = 0;
  for (int i=0; i<b; i++) {
    long long s = 0, x = S[0]-'0';
    for (int j=0; j<N-1; j++) {
      if (i & (1<<j)) x = 10LL*x + (S[j+1]-'0');
      else {
        s += x;
        x = (S[j+1]-'0');
      }
    }
    s += x;
    x = 0;
    m += s;
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
/*
 * <formula> ::= 0 | 1 | 2 | P | Q | R |
 *    -<formula> | (<formula>*<formula>) | (<formula>+<formula>)
 */
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;

int table_seki[3][3];
int table_wa[3][3];
int P,Q,R;

int formula(string& s, int& i);
int main();

int formula(string& s, int& i)
{
	int left=false, right=false;	
	char ope=0;
	bool ans = false;

	switch(s[i])
	{
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case 'P': return P;
		case 'Q': return Q;
		case 'R': return R;
		case '-':
			i++;
			left = formula(s,i);
			if (left == 0) { return 2; }
			else if (left == 2) { return 0; }
			else { return 1; }
		case '(':
			i++;
			left = formula(s,i);
			i++;
			ope = s[i];
			i++;
			right = formula(s,i);
			/*
			dump(left);
			dump(ope);
			dump(right);
			*/
			i++; //)
			if (ope == '*') {
				return table_seki[left][right];
			}
			else {
				return table_wa[left][right];
			}
	}

	return ans;
}

int main() {
	//積集合
	table_seki[0][0] = 0; //y,x
	table_seki[1][0] = 0; //y,x
	table_seki[2][0] = 0; //y,x
	table_seki[0][1] = 0; //y,x
	table_seki[1][1] = 1; //y,x
	table_seki[2][1] = 1; //y,x
	table_seki[0][2] = 0; //y,x
	table_seki[1][2] = 1; //y,x
	table_seki[2][2] = 2; //y,x

	//和集合
	table_wa[0][0] = 0; //y,x
	table_wa[1][0] = 1; //y,x
	table_wa[2][0] = 2; //y,x
	table_wa[0][1] = 1; //y,x
	table_wa[1][1] = 1; //y,x
	table_wa[2][1] = 2; //y,x
	table_wa[0][2] = 2; //y,x
	table_wa[1][2] = 2; //y,x
	table_wa[2][2] = 2; //y,x

	string line;
	vector<int> binary;
	binary.push_back(0);
	binary.push_back(1);
	binary.push_back(2);
	int pattern_cnt = 0;

	while(true) {
		cin >> line;
		pattern_cnt = 0;
		if (line[0] == '.') { break; }

		/*
		//単一パターン
		P = 0; Q = 0; R = 1;
		int i = 0;
		int result = formula(line,i);
		cout << "P=" << P << " Q=" << Q << " R=" << R << " res=" << result << endl;
		*/

		rep(p,3) {
			rep(q,3) {
				rep(r,3) {
					P=p; Q=q; R=r;
					int i = 0;
					int result = formula(line,i);

					//cout << "P=" << P << " Q=" << Q << " R=" << R << " res=" << result << endl;

					if (result == 2) {
						pattern_cnt++;
					}
				}
			}
		}
		cout << pattern_cnt << endl;
	}

	return 0;
}

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

int main() {
 int N , f , x;
 f = 0;
 x = 1;
 cin >> N;
 for (int i=0; i < 8; i++) {
   if ( N / x == 0 ) {
     break;
   }
   else {
   f += N % (x * 10) /x;
   x *= 10;
   }
 }
 if (N % f == 0) {
   cout << "Yes" << endl;
 }
 else {
   cout << "No" << endl;
 }
}

Measured memory_bytes: 3632
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	bool dp[1000000+1]={0};
	dp[0]=1;
	for(int i=0;i<=n;i++)
	{
	   for(int j=100;j<=105;j++)
	   {
	       if(dp[i]==1)
	       dp[i+j]=1;
	   }
	}
	//for(int i=0;i<=n;i++)
//	{deb(i);
//	deb(dp[i]);}
	if(dp[n]==1)
	cout<<1;
	else
	cout<<0;
}

Measured memory_bytes: 1280
N = input()
if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 8916
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int N, M, C, u[2000], v[2000];
int g[128][128], dp[2][128];

int main() {
    for(;;) {
        scanf("%d%d%d", &N, &M, &C);
        if(N==0) return 0;
        rep(i, N) rep(j, N) g[i][j] = i==j ? 0 : INF;
        rep(i, M) {
            int w;
            scanf("%d%d%d", u+i, v+i, &w);
            u[i]--, v[i]--;
            g[u[i]][v[i]] = w;
        }
        rep(k, N) rep(i, N) rep(j, N) g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
        int *cur = dp[0], *nxt = dp[1];
        rep(i, N) cur[i] = g[0][i];
        rep(e, M+1) {
            if(cur[N-1]<=C) {
                printf("%d\n", e);
                break;
            }
            rep(i, N) nxt[i] = cur[i];
            rep(i, M) rep(j, N) nxt[j] = min(nxt[j], cur[u[i]]+g[v[i]][j]);
            swap(cur, nxt);
        }
    }
}

Measured memory_bytes: 832
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while((line = stdin.readLine()) == null);
        var parsed = line.split(" ");
        Long X = Long.valueOf(parsed[0]);
        Long K = Long.valueOf(parsed[1]);
        Long D = Long.valueOf(parsed[2]);
        
        Long sho = Math.abs(X) / D; // まず取りきる回数

        
        Long joyo = Math.abs(X) % D; // 半端数
        Long sign = X >= 0L ? 1L : -1L; //初期場所の符号
        Long maybemin = sign * joyo; // 最小値候補。半端数は符号を無視したので符号を戻してやる
        
                // とりきれなければ分かりやすい
        if (sho > K) {
            System.out.println(Math.abs(X - sign * D * K));
            return;
        }
        
        if ((K - sho) %2 == 0) { // 残り回数が偶数ならそのまま出す
            System.out.println(Math.abs(maybemin));
        } else {
            // 奇数なら最小値候補の符号と逆に動かす。最小値候補
            System.out.println(Math.abs(maybemin - sign * D));
        }
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 32732
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w,ch,cw,dh,dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vs s(h);
    cin >> s;
    vvi dist(h,vi(w,inf));
    dist[ch][cw] = 0;
    deque<P> q;
    q.eb(ch,cw);
    while (q.size()) {
        auto [i,j] = q.front();
        q.pop_front();
        rep(k,4) {
            int ni = i+dx[k],nj = j+dy[k];
            if(ni < 0 or ni >= h or nj < 0 or nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(chmin(dist[ni][nj],dist[i][j])) q.emplace_front(ni,nj);
        }
        rep2(ni,max(0,i-2),min(h-1,i+2)+1) {
            rep2(nj,max(0,j-2),min(w-1,j+2)+1) {
                if(ni == i and nj == j) continue;
                if(s[ni][nj] == '#') continue;
                if(chmin(dist[ni][nj],dist[i][j]+1)) q.emplace_back(ni,nj);
            }
        }
    }
    cout << (dist[dh][dw] == inf ? -1 : dist[dh][dw]) << endl;
}

Measured memory_bytes: 8692
# Binary Indexed Tree (Fenwick Tree)
class BIT():
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, value):
        i = i + 1
        while i <= self.n:
            self.bit[i] += value
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

n = int(input())
S = input()
q = int(input())
Query = [input().split() for _ in range(q)]

bits = [BIT(n) for i in range(26)]
s = []
for i,c in enumerate(S):
    bits[ord(c) - ord("a")].add(i,1)
    s.append(c)

for q_type,fr,to in Query:
    if q_type == "1":
        i = int(fr)-1
        bits[ord(s[i]) - ord("a")].add(i,-1)
        bits[ord(to) - ord("a")].add(i,1)
        s[i] = to
    else:
        l,r = int(fr)-1,int(to)
        tmp = 0
        for i in range(26):
            if bits[i].sum(l,r):
                tmp += 1
        print(tmp)



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

using namespace std;

int solve(string &s, int offset = 0, bool is_less = false, bool has3 = false,
          bool has5 = false, bool has7 = false) {
  if (offset == s.size()) {
    return has3 && has5 && has7;
  }

  vector<int> elms{0, 3, 5, 7};
  int d = s[offset] - '0';
  int ans = 0;
  for (int i = 0; i < elms.size(); ++i) {
    if (!is_less && d < elms[i]) {
      continue;
    }

    if ((has3 || has5 || has7) && elms[i] == 0) {
      continue;
    }

    ans += solve(s, offset + 1, is_less || (d > elms[i]), has3 || elms[i] == 3,
                 has5 || elms[i] == 5, has7 || elms[i] == 7);
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  cout << solve(s) << '\n';
  return 0;
}

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

using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i=min(a,b);i>0;i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      if(cnt == k){
	cout << i << endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC116
{
    class Program
    {
        static void Main(string[] args)
        {
            int ab, bc, ac, x;
            var word = Console.ReadLine().Split(' ');

            ab = int.Parse(word[0]);
            bc = int.Parse(word[1]);
            ac = int.Parse(word[1]);



            x = ab * bc / 2;

            Console.WriteLine(x);
            Console.ReadKey();

            
        }
    }
}


Measured memory_bytes: 13140
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

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: 3592
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int dp[125][65][3505]; // 1 ~ i 分配了多少个红色 总和是若干 方法数
int a[2][65];
int s[2][65];
int p[125];
int n, k;
const int inf = 1e9;
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]);
	sort(p + 1, p + n + 1);
	reverse(p + 1, p + n + 1);
	for (int j = 0; j < 2; j++) {
		for (int q = 1; q <= k; q++) 
			scanf("%d", &a[j][q]);
		sort(a[j] + 1, a[j] + k + 1);
		reverse(a[j] + 1, a[j] + k + 1);
		for (int q = 1; q <= k; q++)
			s[j][q] = s[j][q - 1] + a[j][q];
	}
	for (int i = 0; i < 125; i++)
		for (int j = 0; j < 65; j++)
			for (int k = 0; k < 3505; k++)
				dp[i][j][k] = inf;
	for (int j = n + 1; j >= 1; j--) {
		int ss = 0;
		for (int l = 1; l < j; l++) ss += p[l];
		for (int m = 0; m <= k; m++)
			for(int u = 0; u <= 50 * m; u++) {
				int d[2] = {m, j - 1 - m};
				int q[2] = {u, ss - u};
				if (d[0] > k || d[1] > k || d[0] < 0 || d[1] < 0) dp[j][m][u] = inf;
				else {
					if (j == n + 1) {
						if (q[0] > s[0][k] || q[1] > s[1][k]) dp[j][m][u] = inf;
						else {
						//	cout << "!!!" << u << endl;
							dp[j][m][u] = 0;
						}
					}
					else {
						dp[j][m][u] = inf;
						for (int tr = 0; tr < 2; tr++) {
							int cp = max(0, p[j] - a[tr][d[tr] + 1]);
							int em = m, eu = u;
							if (tr == 0) em++, eu += p[j];
							dp[j][m][u] = min(dp[j][m][u], dp[j + 1][em][eu] + cp);
						}
					}
				}
			}
	}
	int ans = dp[1][0][0];
	if (ans > 1e8) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}



Measured memory_bytes: 114468
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const long long INF = 1e18;
const int MX = 1e5 + 5;

int N,W;
long long dp[105][100005];
int K[105];
int V[105];

long long solve(int x, int rem) {
    if (x >= N) return rem == 0 ? 0 : INF;
    if (rem == 0) return 0;
    if (dp[x][rem] != -1) return dp[x][rem];

    long long take = INF;
    if (rem - V[x] >= 0) take = K[x] + solve(x + 1, rem - V[x]);

    long long dont_take = solve(x + 1, rem);
    return dp[x][rem] = min(take, dont_take);
}

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

    memset(dp, -1, sizeof(dp));
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> K[i];
        cin >> V[i];
    }

    long long res = -1;
    for (int i = 0; i < MX; i++) {
        long long mw = solve(0, i);
        if (mw <= W) {
            res = i;
        }
    }

    cout << res << "\n";
}



Measured memory_bytes: 82304
n = int(input())
h_list = [int(h) for h in input().split()]

def count_watering(h_list):
    count = 0
    temp = min(h_list)
    if temp > 0:
        count += temp
        h_list = [h - temp for h in h_list]
    
    l = r = 0
    for i in range(len(h_list)):
        if h_list[i] > 0:
            r = i + 1
            continue
        
        if l != r:
            count += count_watering(h_list[l:r])
        l = r = i + 1
    else:
        if l != r:
            count += count_watering(h_list[l:r])
    
    return count

print(count_watering(h_list))

Measured memory_bytes: 9184
import math
import bisect

N = int(input())

a = list(map(int,input().split()))

a.sort()



l = a[-1]
del a[-1]
a.append(float("inf"))


poi = bisect.bisect_left(a,l / 2)


if poi > 0:

    if abs(l / 2 - a[poi]) > abs(l / 2 - a[poi-1]):
        print (l,a[poi-1])
    else:
        print (l,a[poi])

else:

    print (l,a[poi])



Measured memory_bytes: 62704
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
//const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int mod = 2020;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n, int m) {
  if (n == 0) return 1;
  mint x = f(n/2,m);
  x *= x;
  if (n%2 == 1) x *= m;
  return x;
}

int main() {
    int n; cin >> n;
    vector<int> ans(n);
    rep(i,n){
        int a; cin >> a;
        ans[a-1] = i+1;
    }
    printvec(ans);
}

Measured memory_bytes: 1152
#include<stdio.h>
#define ll long long

int main(){
	ll n, rev, i = 0;
	scanf("%lld", &n);
	char str[100];
	while(n){
		n--;
		rev = n % 26;
		n /= 26;
		str[i] = 'a' + rev;
		i++;
	}
	for(ll j = i - 1; j >= 0; j--){
		printf("%c", str[j]);
	}
	puts("");
	return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    int n, k;
    cin >> n >> k;

    print((n + 1) / 2 >= k ? "YES" : "NO");

    return 0;
}


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

int main()
{
  float a, b;
  
  cin >> a >> b;
  
  for (int i = 1; i < 1009; i++)
  {
    if(floor(i * 0.08f) == a && floor(i * 0.1f) == b)
    {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
}


Measured memory_bytes: 384
from operator import itemgetter

N, M = map(int, input().split())
dic = {}
A = list(map(int, input().split()))
for a in A:
    if not a in dic.keys():
        dic[a] = 1
    else:
        dic[a] += 1

for _ in range(M):
    b, c = map(int, input().split())
    if not c in dic.keys():
        dic[c] = b
    else:
        dic[c] += b
    
#print(dic)
L = list(dic.items())
L.sort(reverse=True, key=itemgetter(0))

c = 0
ans = 0
for k, v in L:
    if c + v >= N:
        ans += (N-c)*k
        break
    ans += k*v
    c += v
print(ans)

Measured memory_bytes: 43040
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,h=map(int,readline().split())
    li=[list(map(int,readline().split())) for _ in range(n)]
    li.sort(key=lambda x:x[1])
    a_max=0
    j=-1
    for i in range(n):
        if a_max<li[i][0]:
            a_max=li[i][0]
            j=i
    flags=[True]*n
    is_killed=False
    cnt=0
    for i in range(n-1,-1,-1):
        if i==j:
            if h<=li[i][1]:
                cnt+=1
                is_killed=True
                break
        elif a_max<li[i][1]:
            cnt+=1
            flags[i]=False
            h-=li[i][1]
            if h<=0:
                is_killed=True
                break
        else:
            break

    if is_killed:
        print(cnt)
    else:
        if h<=li[j][1]:
            cnt+=1
        elif li[j][0]>=li[j][1]:
            cnt+=(h+a_max-1)//a_max
        else:
            cnt+=1
            h-=li[j][1]
            cnt+=(h+a_max-1)//a_max
    
        print(cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 28992
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n,m;
        n = sc.nextInt();   //人数
        m = sc.nextInt();   //種類数

        int count[] = new int[m+1];
        for(int i=0; i<n; i++){
            int k = sc.nextInt();   //好きな種類数
            for(int j=0; j<k; j++){
                int a = sc.nextInt();   //種類番号
                count[a]++;
            }
        }

        int cnt = 0;
        for(int i=1; i<=m; i++){
            if(count[i] == n) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22356
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		boolean flg = true;
		for(int i = 0;i < s.length;i++){
			if(i % 2 == 0){
				if(s[i].equals("R") || s[i].equals("U") || s[i].equals("D")){

				} else {
					flg = false;
				}
			} else {
				if(s[i].equals("L") || s[i].equals("U") || s[i].equals("D")){

				} else {
					flg = false;
				}
			}
		}
		if(flg){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

const int mod = 1000000007;

vector <int> from[100010];
long long dp[100010][2];

void dfs(int x, int last){
	dp[x][0] = dp[x][1] = 1;
	for (int i = 0; i < from[x].size(); i++){
		int v = from[x][i];
		if (v == last) continue;
		dfs(v, x);
		dp[x][0] = (dp[x][0] * ((dp[v][0] + dp[v][1]) % mod)) % mod;
		dp[x][1] = dp[x][1] * dp[v][0] % mod;
	}
	return ;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		from[u].push_back(v);
		from[v].push_back(u);
	}
	dfs(1, 1);
	printf("%lld\n", (dp[1][0] + dp[1][1]) % mod);
	return 0;
}


Measured memory_bytes: 14208
#!python3.4
# -*- coding: utf-8 -*-
# abc155/abc155_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    ABC = set(i2nn())
    print('Yes' if len(ABC) == 2 else 'No')
    return

main()


Measured memory_bytes: 3064
S = input()
S = S[::-1]

last = ['maerd', 'remaerd', 'esare', 'resare']
length = [5, 7, 5, 6]

index = 0
while index < len(S):
    for i, tail in enumerate(last) :
        sub = S[index:index + length[i]]
        if sub == tail :
            index += length[i]
            break
    else :
        print('NO')
        break
else :
    print('YES')

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

using namespace std;

string s;
char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main(){
    long int N,ans = 0;
    vector<int> al(26,0);
    bool ana;
    cin >> N;
    vector< vector<int>> snum(N,al);
    map<string,int> map;

    for(int i = 0;i < N; i++){
        cin >> s;
        sort(s.begin(),s.end());
        if(map.find(s) == map.end()){
            map[s] = 1;
        }
        else{
            ans += map[s];
            map[s]++;
        }
        /*for(int a = 0;a<26;a++){
            snum[i][a] = count(s[i].begin(),s[i].end(),alpha[a]);
        }*/
    }
    /*sort(snum.begin(),snum.end());
    for(int i = 0;i < N-1; i++){
        for(int j = i+1; j<N; j++){
            if(snum[i] == snum[j]){
                ans ++;
            }
            else break;
        }
    }*/
    cout << ans << endl;
}

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

int main(){
    long long  X;
    cin >> X;
    int count = 0;
    long long yokinn = 100;
    for(int i = 0;;i++){
        yokinn *= 1.01;
        count ++;
        if(yokinn >= X){
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
from fractions import gcd


def lcm(a, b):
    return a // gcd(a, b) * b


def f(x):
    res = 0
    while x % 2 == 0:
        x //= 2
        res += 1
    return res


n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
b = 1
c = f(a[0])
for i in range(n):
    if f(a[i]) != c:
        print(0)
        exit()
    a[i] >>= c
    b = lcm(b, a[i])
m >>= c
if b > m:
    print(0)
    exit()

m //= b
ans = (m + 1) // 2
print(ans)


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

int main() 
{ 
    int n;
    cin>>n;
    int v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n);
    for(int i=0;i<n-1;i++){
        if(v[i]==v[i+1]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
} 


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

vector<ll> G[MAX];
bool visited[MAX];

int main(void) {
    ll N, M;
    cin >> N >> M;
    ll x, y;
    ll num[MAX];
    ll red[MAX];
    ll i;
    
    for(i=0; i<N; i++) {
        num[i]=1;
        red[i]=false;
    }
    red[0]=true;
    
    for(i=0; i<M; i++) {
        cin >> x >> y;
        x--; y--;
        
        if(red[x]) red[y]=true;
        num[x]--;
        num[y]++;
        if(num[x]==0) red[x]=false;
    }
    ll ans=0;
    for(i=0; i<N; i++) {
        if(red[i])
            ans++;
    }
    prin(ans);
    
}

Measured memory_bytes: 4096
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll h,w;cin>>h>>w;
  vector<vector<char> > a(h,vector<char>(w));
  rep(i,h){
    rep(j,w)cin>>a[i][j];
  }
  ll dp[h][w];
  rep(i,h){
    rep(j,w)dp[i][j];
  }
  rep(i,h){
    vector<char> b=a[i];
    ll part=INF;
    rep(j,w){
      if(b[j]=='#')part=0;
      else part++;
      dp[i][j]=part;
    }
    reverse(b.begin(),b.end());
    part=INF;
    rep(j,w){
      if(b[j]=='#')part=0;
      else part++;
      dp[i][w-1-j]=min(part,dp[i][w-1-j]);
    }
  }
  rep(i,h-1){
    rep(j,w)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
  }
  for(ll i=h-1;i>=1;i--){
    rep(j,w)dp[i-1][j]=min(dp[i-1][j],dp[i][j]+1);
  }
  ll ans=0;
  rep(i,h){
    rep(j,w)ans=max(ans,dp[i][j]);
  }
  cout<<ans<<endl;
}

  

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
signed main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a>k)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}



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

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

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)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(A, B),
    get_number(C, D),
    X is min(A, B),
    Y is min(C, D),
    Z is X + Y,
    writeln(Z).


Measured memory_bytes: 8020