akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main()
{
	int N, M, X;
	int C[12];
	int A[12][12];
	scanf("%d%d%d", &N, &M, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &C[i]);
		for (int t = 0; t < M; t++) {
			scanf("%d", &A[i][t]);
		}
	}

	const int INF = 1 << 30;
	int ans = INF;
	for (int bit = 0; bit < (1 << N); bit++) {
		int skill[12] = {0};
		int cost = 0;
		for (int i = 0; i < N; i++) {
			int use = (bit & (1 << i));
			if (use) {
				cost += C[i];
				for (int t = 0; t < M; t++) {
					skill[t] += A[i][t];
				}
			}
		}
		bool ok = true;
		for (int t = 0; t < M; t++) {
			if (skill[t] < X) {
				ok = false;
			}
		}
		if (ok) {
			ans = (cost < ans) ? cost: ans;
		}
	}

	if (ans == INF) {
		puts("-1");
	}
	else {
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    long long ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + key % (M - 1);
}

int getChar(char ch){
  if (ch == 'A') {
    return 1;
  }else if (ch == 'C') {
    return 2;
  }else if (ch == 'G') {
    return 3;
  }else if (ch == 'T') {
    return 4;
  }else{
    return 0;
  }
}


long long getKey(char str[]){
  long long sum = 0, p = 1;
  for(int i = 0; i < strlen(str); i++){
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}


int insert(char str[]){
  long long key, h;
  key = getKey(str);
  for(int i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h],str) == 0) {
      return 1;
    }else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int find(char str[]){
  long long key, h;
  key = getKey(str);
  for(int i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0 ) {
      return 1;
    }
    else if (strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}

int main(int argc, char const *argv[]) {
  int n, h;
  char str[L], com[9];
  for(int i = 0; i < M; i++)  H[i][0] = '\0';
  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    }else{
      if (find(str)) {
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }

  return 0;
}

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

using namespace std;


int a[108000], n;
int main(){
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> a[i];
  }
  int now = 1, res = -1;
  for(int i = 0;i < n + 108;i++){
    if(now == 2){
      res = i;
      break;
    }
    now = a[now];
  }
  cout << res << endl;
  return 0;  
}

Measured memory_bytes: 640
#include <stdio.h>
#include <new>

int main(void)
{
  int n,m,l;
  int i,j,k;

  //n,m,l?????\???
  scanf("%d%d%d",&n,&m,&l);

  //A,B,C?????????????¢????
  int**A = new int*[n];
  for(i=0; i<n; i++){
    A[i] = new int[m];
  }

  int**B = new int*[m];
  for(i=0; i<m; i++){
    B[i] = new int[l];
  }

  long int**C = new long int*[n];
  for(i=0; i<n; i++){
    C[i] = new long int[l];
  }

  //C??????????????¨???0???
  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      C[i][j] = 0;
    }
  }
  
  //A,B?????\???
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d",&A[i][j]);
    }
  }

  for(i=0; i<m; i++){
    for(j=0; j<l; j++){
      scanf("%d",&B[i][j]);
    }
  }
  
 
  //??????C????????????
  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      for(k=0; k<m; k++){
	C[i][j] = C[i][j] + (A[i][k] * B[k][j]);
      }
    }
  }

  //C?????????
  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      printf("%ld",C[i][j]);
      if(j==(l-1))
	puts("");
      else
	printf(" ");
    }
  }
  
  //?¢???????????????????????????????
  for(i=0; i<n; i++){
    delete[] A[i];
    delete[] C[i];
  }
  delete[] A;
  delete[] C;

  for(i=0; i<m; i++){
    delete[] B[i];
  }
  delete[] B;

  return(0);
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;

	

	int size=s.size();
	bool flag = true;

	if (s[a] == '-') {
		for (int i = 0; size > i; i++) {
			if (i == a) continue; //判定済み
			if (s[i] == '-') {
				flag = false;
			}
		}
	}
	else {
		flag = false;
	}

	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
	ll t,p,r;
	while(scanf("%*lld%lld%lld%lld",&t,&p,&r),t){
		ll a[60][20]={};
		ll f[60][20]={};
		while(r--){
			ll x,i,j,q;
			scanf("%lld%lld%lld%lld",&x,&i,&j,&q);
			if(q)a[i][j]+=20;
			else{
				a[i][j]+=x;
				f[i][j]=1;
			}
		}
		ll temp[60]={};
		rep(i,1,t+1){
			ll co=0,ti=0;
			rep(j,1,p+1)if(f[i][j]){
				co++;
				ti+=a[i][j];
			}
			temp[i]=co*2700000-ti*60+i;
		}
		sortdown(temp+1,t);
		rep(i,1,t+1){
			printf("%d",temp[i]%60);
			if(i!=t)printf("%c",temp[i]/60==temp[i+1]/60?'=':',');
		}
		puts("");
	}
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b; 
    int ans = min(n * a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int count = 0;
		int ans = 0;
		int num = 0;
		for(int i = 1; i <= a; i++) {
			num = i;
			while(num != 0) {
				num = num / 10;
				count++;
			}
			if(!(count % 2 == 0)){
				ans++;
			}
			count = 0;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//A Holiday of Miss Brute Force
public class Main{

	int[][][] dist;
	int sx, sy, gx, gy, lx, ly;
	
	boolean ok(int x, int y){
		return -lx+100<=x&&x<=lx+100&&-ly+100<=y&&y<=ly+100;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		boolean[][] rock = new boolean[201][201];
		sx = sc.nextInt()+100; sy = sc.nextInt()+100;
		gx = sc.nextInt()+100; gy = sc.nextInt()+100;
		int n = sc.nextInt();
		while(n--!=0)rock[sc.nextInt()+100][sc.nextInt()+100] = true;
		lx = sc.nextInt(); ly = sc.nextInt();
		dist = new int[201][201][6];
		int INF = 1<<28;
		for(int i=0;i<=200;i++)for(int j=0;j<=200;j++)for(int k=0;k<6;k++)dist[i][j][k]=INF;
		dist[sx][sy][0] = 0;
		PriorityQueue<int[]> q = new PriorityQueue<int[]>(256, new Comparator<int[]>() {
			public int compare(int[] o1, int[] o2) {
				return dist[o1[0]][o1[1]][o1[2]] - dist[o2[0]][o2[1]][o2[2]];
			}
		});
		q.add(new int[]{sx, sy, 0});
		int[][] even = {{0, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}};
		int[][] odd = {{0, 1}, {1, 1}, {1, 0}, {0, -1}, {-1, 0}, {-1, 1}};
		while(!q.isEmpty()){
			int[] V = q.poll();
			int x = V[0], y = V[1], t = V[2], dir = (Math.abs(x-100)*Math.abs(y-100)*t)%6;
			if(dist[x][y][t]+1 < dist[x][y][(t+1)%6]){
				dist[x][y][(t+1)%6] = dist[x][y][t] + 1;
				q.add(new int[]{x, y, (t+1)%6});
			}
			for(int k=0;k<6;k++){
				int nx = x + ((x&1)==0?even[k][0]:odd[k][0]), ny = y + ((x&1)==0?even[k][1]:odd[k][1]);
				int w = dist[x][y][t] + (k==dir?0:1);
				if(ok(nx, ny) && !rock[nx][ny] && w < dist[nx][ny][(t+1)%6]){
					dist[nx][ny][(t+1)%6] = w;
					q.add(new int[]{nx, ny, (t+1)%6});
				}
			}
		}
		int res = INF;
		for(int k=0;k<6;k++)res = Math.min(res, dist[gx][gy][k]);
		System.out.println(res==INF?-1:res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b; string s;
    cin>>a>>b>>s;
    bool ok=true;
    rep(i,s.size()){
        if(s[a]!='-') ok=false;
        else if(i==a) continue;
        else if(!('0'<=s[i] && s[i]<='9')) ok=false; 
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

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

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long K, std::vector<long long> x) {
  long long ans = 0;
  for(int i = 0 ; i < N ; i++){
      ans += min(K-x[i], x[i]);
  }
  cout << ans * 2 << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
  }
  solve(N, K, std::move(x));
  return 0;
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define pii pair<int, int>

const int MAXN = 1009;
bool a[MAXN][MAXN];
int dist[MAXN][MAXN];
int n, m;
int inf = 1000 * 1000 * 1000;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

bool w(int i, int e)
{
    return i >= 0 && e >= 0 && i < n && e < m;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    queue<pii> q;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int e = 0; e < m; e++)
        {
            a[i][e] = (s[e] == '#');
            dist[i][e] = inf;
            if (a[i][e])
            {
                dist[i][e] = 0;
                q.emplace(i, e);
            }
        }
    }
    int ans = 0;
    while (!q.empty())
    {
        pii x = q.front();
        q.pop();
        ans = dist[x.ff][x.ss];
        for (int j = 0; j < 4; j++)
        {
            pii y(x.ff + dx[j], x.ss + dy[j]);
            if (w(y.ff, y.ss) && dist[y.ff][y.ss] > dist[x.ff][x.ss] + 1)
            {
                dist[y.ff][y.ss] = dist[x.ff][x.ss] + 1;
                q.emplace(y.ff, y.ss);
            }
        }
    }
    cout << ans;
}


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

const int MAX_N = (1<<21);
const ll INF = LLONG_MAX;
// RMQ
class RMQ{
  int n;
  ll dat[2*MAX_N-1];

public:
  RMQ(int _n = MAX_N){
    n = 1;
    while(n < _n) n *= 2;
    fill(dat,dat+2*n-1,INF);
  }

  // k番目の値をaに変更
  void update(int k, ll a){
    k += n - 1;
    dat[k] = a;
    while(k > 0){
      k = (k - 1) / 2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }

  // [a,b) の最小値を求める
  ll query(int a, int b){ return query(a, b, 0, 0, n);}
  ll query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return dat[k];
    else{
      ll vl = query(a, b, k*2+1, l, (l+r)/2);
      ll vr = query(a, b, k*2+2, (l+r)/2, r);      
      return min(vl,vr);
    }
  }  
};


int N;
ll A[200005];
ll L[200005];
ll R[200005];
RMQ rmq;

int getL(int id){
  int st = 0, ed = id;
  int k = id;
  while( st <= ed ){
    int h = (st+ed)/2;
    ll r = rmq.query( h, id );
    if( r > A[id] ) {
      k = h; ed = h-1;
    } else
      st = h+1;
  }
  return abs( id - k )+1;
}
int getR(int id){
  int st = id, ed = N-1;
  int k = id;
  while( st <= ed ){
    int h = (st+ed)/2;
    ll r = rmq.query( id+1, h+1 );
    if( r > A[id] ) {
      k = h; st = h+1;
    } else
      ed = h-1;
  }
  return abs( id - k )+1;  
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    rmq.update( i, A[i] );
  }

  ll res = 0;
  for(int i=0;i<N;i++){
    ll l = getL( i ), r = getR( i );
    res += l * r * A[i];    
  }
  cout << res << endl;
}


Measured memory_bytes: 34560
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let sum: i32 = n.to_string().chars().map(|c| c as i32 - 48).sum();

    println!("{}", if n % sum == 0 { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll lhs=4*a*b;
  ll rhs=(c-a-b)*(c-a-b);
  
  
  if(c-a-b<0)cout<<"No";
  else  if(rhs>lhs)cout<<"Yes";
  else cout<<"No";
  
  
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iterator>

using namespace std;

int t[20][20];

int dp[0x3FFFF];

int main(void) {
    while(1) {
        int n;
        scanf("%d",&n);
        if(!n) break;

        fill(begin(dp), end(dp), 0xFFFFF);

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

        dp[0] = 0;
        for(int x=0; x<(1<<n); x++) {
            for(int nt=0; nt<n; nt++) {
                int mnt = 1<<nt;
                if(x & mnt) continue;
                dp[x | mnt] = min( dp[x | mnt], dp[x] + t[nt][0]);
                for(int soubi=1; soubi<=n; soubi++) {
                    int msoubi = 1<<(soubi-1);
                    if(!(x & msoubi)) continue;
                    dp[x | mnt] = min( dp[x | mnt], dp[x] + t[nt][soubi] );
                }
            }
//            printf(":%08x, %d\n", x, dp[x]);
        }

        printf("%d\n", dp[(1<<n)-1]);


    }
    return 0;
}

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

int main() {
	vector<vector<int>> card(3,vector<int>(3)), check(3, vector<int>(3,0));
	int n,num;
	bool bingo = false;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> card.at(i).at(j);
		}
	}
	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> num;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (num == card.at(i).at(j) && check.at(i).at(j) == 0)check.at(i).at(j) = 1;
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		if (check.at(i).at(0) == check.at(i).at(1) && check.at(i).at(0) == check.at(i).at(2) && check.at(i).at(0) == 1)bingo = true;
		if (check.at(0).at(i) == check.at(1).at(i) && check.at(0).at(i) == check.at(2).at(i) && check.at(0).at(i) == 1)bingo = true;
	}
	if (check.at(0).at(0) == check.at(1).at(1) && check.at(0).at(0) == check.at(2).at(2) && check.at(0).at(0) == 1)bingo = true;
	if (check.at(0).at(2) == check.at(1).at(1) && check.at(0).at(2) == check.at(2).at(0) && check.at(0).at(2) == 1)bingo = true;

	if (bingo)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int n,m,a,s;

int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        s+=a;
    }
    if(s>n)cout<<-1<<endl;
    else cout<<n-s<<endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    string S;
    cin>>S;
    int size = S.size();
    long res=0;
    
    for(long bit=0;(1<<size-1)>bit;bit++){
        long index=0;
        for(int i=0;i<size;i++){
            if(bit & (1<<i)){
                res += stol(S.substr(index,i-index+1));
                index = i+1; 
            }
            if(i==size-1){
                res += stol(S.substr(index));
            }  
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import sys
from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
if n == 1:
    if a[0] == 0:
        print 1
        sys.exit()
c = 0
if n&1:
    if a[0] == 0:
        del a[0]
        d = Counter(a)
        for i in d.keys():
            if i == 0:
                print 0
                sys.exit()
            if i&1:
                print 0
                sys.exit()
            if not(i&1):
                if d[i] == 2:
                    c += 1
                if d[i] != 2:
                    print 0
                    sys.exit()
    if c == (n-1)//2:
        print (1 << c)%(10**9+7)
if not(n&1):
    d = Counter(a)
    for i in d.keys():
        if i&1:
            if d[i] == 2:
                c +=1
            if d[i] != 2:
                print 0
                sys.exit()
        if not(i&1):
            print 0
            sys.exit()
    if c == n//2:
        print (1 << c)%(10**9+7)

Measured memory_bytes: 11564
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string a;
    cin >> a;
    int ans = 0;
    rep(i,3){
        if(a[i] == 'o') ans++;
    }
    cout << 700+ans*100 << endl;
    return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s; cin >> s;
  set<char> st;
  rep(i, 3)st.insert(s[i]);
  if(sz(st) == 1)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int k,a,b;
    cin >> k>>a>>b;
    
for(int i=0;i*k<=1000;i++){
  if(i*k>=a && i*k<=b){
    cout<<"OK"<<endl;
    return 0;
  }
}
cout<<"NG"<<endl;
   
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int n1 = Integer.parseInt(S.substring(0, 2));
		int n2 = Integer.parseInt(S.substring(2, 4));

		if (n1==0 && n2==0) {
			System.out.println("NA");
			return;
		} else if (n1==0 && n2<=12) {
			System.out.println("YYMM");
			return;
		} else if (n1<=12 && n2==0) {
			System.out.println("MMYY");
			return;
		} else if (n1<=12 && n2<=12) {
			System.out.println("AMBIGUOUS");
			return;
		} else if (n1!=0 && n1<=12 && n2>12) {
			System.out.println("MMYY");
			return;
		} else if (n1>12 && n2!=0 && n2<=12) {
			System.out.println("YYMM");
			return;
		} else {
			System.out.println("NA");
			return;
		}
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int inf = 1000000007;

int n,a[maxn],T;
int f[maxn][2];

int main() {
   // freopen("in.cpp","r",stdin);
    cin>>n>>T;
    for(int i=1;i<=n;i++)cin>>a[i];
    f[n][0]=1;
    f[n][1]=n;
    for(int i=n-1;i>=1;i--){
        int pos = f[i+1][1];
        if(a[i]==a[pos]){
            f[i][0]=f[i+1][0]+1;
            f[i][1]=f[i+1][1];
        } else if(a[i]<a[pos]){
            f[i][0]=f[i+1][0];
            f[i][1]=f[i+1][1];
        } else {
            f[i][0] = 1;
            f[i][1] = i;
        }
    }
    int ret=0;
    int mi = inf;
    int mx = 0;
    for(int i=1;i<=n;i++){
        mx = max(mx, a[i]-mi);
        mi = min(mi, a[i]);
    }
    mi = inf;
    int cmi = 0;
    for(int i=1;i<=n;i++){
        if(a[i]==mi){
            cmi++;
        } else if(a[i]<mi){
            mi = a[i];
            cmi=1;
        }
        int pos = f[i][1];
        if(a[pos]==a[i]&&a[i]-mi==mx){
            ret+=min(cmi,f[i][0]);
            cmi = 0, mi = inf;
            i = pos;
        }
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	ll a, b, c, x, y, z, ans;
	cin >> a >> b >> c;
	if(a%2==0 || b%2==0 || c%2==0){
		cout << 0 << endl;	
	} else {
		x=a*b;
		y=b*c;
		z=c*a;
		ans=min(x, y);
		ans=min(ans, z);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut map: BTreeMap<String, usize> = BTreeMap::new();
    for si in s {
        if map.contains_key(&si) {
            let x = map.get_mut(&si).unwrap();
            *x += 1;
        } else {
            map.insert(si, 1);
        }
    }
    let mut max_cnt = 0;
    for (_, &v) in &map {
        max_cnt = max(max_cnt, v);
    }

    for (k, v) in map {
        if v == max_cnt {
            println!("{}", k);
        }
    }
}

Measured memory_bytes: 26876
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{ 
    ll n;
    cin>>n;
    ll s;
    bool flag=false;
    while(n!=0){
    	s=n%10;
    	if(s==7){
    		flag=true;
    		break;
    	}
    	n/=10;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  string s,t; cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  bool f = false;
  
  int i = 0, j = 0;
  while(1) {
    if( s[i] < t[j] ) {
      f = true;
      break;
    } else if ( s[i] == t[j] ) {
      if( i+1 <= s.length() && j+1 <= t.length() ) {
	i++;
	j++;
      } else if ( i == s.length() && j+1 <= t.length() && i <= j ) {
	f = true;
	break;
      } else if ( i+1 <= s.length() && j == t.length() && i >= j ) {
	f = false;
	break;
      }
    } else {
      f = false;
      break;
    }
    if ( i == s.length()-1 && j == t.length()-1 ) {
      f = false;
      break;
    }
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
k=int(input())
x=list(map(int,input().split()))
sum=[]
for i in range(n):
    if k-x[i]>=x[i]:
        sum.append(2*x[i])
    else:
        sum.append(2*(k-x[i]))
ans=0
for i in range(n):
    ans+=sum[i]
print(ans)

Measured memory_bytes: 3064
from sys import exit
N, M = map(int, input().split())
line = []
for i in range(M):
  line.append([int(i) for i in input().split()])
for i in range(10 ** N):
  i_keta = [i // 100, (i % 100) // 10, i % 10]
  correct = True
  for test in line:
    s = test[0]
    c = test[1]
    if s == 1:
      if N >= 2:
        if i_keta[3 - N] == 0 or i_keta[3 - N] != c:
          correct = False
          break
      elif i_keta[2] != c:
        correct = False
        break
    else:
      if i_keta[s - N + 2] != c:
        correct = False
        break
  if correct:
    if N >= 2 and i_keta[3 - N] != 0:
      print(i)
      exit()
    elif N == 1:
      print(i)
      exit()
print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#include<sstream>
#define h 100
#define ll  long long
#define pb push_back
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, c, k, cnt=0;
  cin>>a>>b>>c>>k;
  if(b<=a) 
  {
  	while(b<=a) 
  	{b*=2;cnt+=1;} 
  } 
  if(c<=b) 
  {
  	while(c<=b) 
  	{c*=2;cnt+=1;} 
  } 
  if(cnt<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
} 


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k,i,j,l;
	cin>>n;
	vector< pair<ll,ll> > vc;
	for(i=1;i<=n;i++){
		cin>>k;
		vc.ps({k,i});
	}
	sort(all(vc));
	for(auto it:vc){
		cout<<it.sc<<" ";
	}
	return 0;
}

Measured memory_bytes: 2544
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int a[3];
    for(int i = 0;i < 3;i++)
    {
        cin >> a[i];
        if(a[i] % 2 == 0)
        {
            cout << "0\n";
            return 0;
        }
    }
    sort(a,a + 3);
    cout << a[0] * a[1] << "\n";
    
    return 0;
}

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

int data[10][6]={
  {5,'.',',','!','?',' '},
  {3,'a','b','c',0,0},
  {3,'d','e','f',0,0},
  {3,'g','h','i',0,0},
  {3,'j','k','l',0,0},
  {3,'m','n','o',0,0},
  {4,'p','q','r','s',0},
  {3,'t','u','v',0,0},
  {4,'w','x','y','z',0}
};

int main(){
  int n;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<s.length();j++){
      if(s[j]=='0')continue;
    int tmp=j;
    while(s[j]!='0')j++;

    int button=s[j-1]-'0'-1;
    int cnt=(j-tmp-1)%data[button][0] + 1;

    cout << (char)data[button][cnt];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
n, m = map(int, input().split())
d = {}
for i in range(m):
    p, s = input().split()
    d.setdefault(p, [])
    d[p].append(s)

cnt = 0; correct = 0
for v in d.values():
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC") 

print(correct, cnt)

Measured memory_bytes: 31564
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
vector<int> V;
int C[210][210],n,len;
char S[210];
ll ans;
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void calc(){
	int nd=0,k1=0,k2=0;
	for(int i=1;i<=len;i++){
		if(k1<V.size()&&S[i]=='r') k1++;
		else if(k2<k1&&V[k2]>0&&S[i]=='b') nd+=V[k2++]-1;
		else if(nd) nd--;
	}
	if(nd||k1<V.size()||k2<k1&&V[k2]>0) return;
//	for(auto x:V) cerr<<x<<' ';cerr<<'\n';
	int used=V.size()-1,pos=used+2;
	for(int i=0;i<V.size();i++) used+=max(1,V[i]*2-1),pos+=V[i]*2+1;
	ll now=C[pos+n-used-1][n-used];
	ll p=0,res=1;
	for(int i=0;i<V.size();i++){
		if(i==0||V[i]==V[i-1]){
			res=res*++p%mod;
		}
		else now=now*fp(res,mod-2)%mod,res=1,p=1;
		now=now*(i+1)%mod;
	}
	ans=(ans+now*fp(res,mod-2))%mod;
}
void solve(int n,int lim){
	if(V.size()) calc();
	for(int i=lim;~i;i--)
		if(max(1,2*i-1)<=n){
			if(max(1,2*i-1)==n&&V.size()) continue;
			V.push_back(i);
			solve(n-max(2*i-1,1)-(V.size()!=1),i);
			V.pop_back();
		}
}
int main(){
	read(n);read(len);
	cin>>S+1;ans=1;
	for(int i=0;i<=150;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	solve(n,n);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 998244353
#pragma GCC optimize("-O2")
#define mod3 127
#define mod 1000000007
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector<vector<int>>
#define v4096 vector<vector<lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli, lli>
#define m32 map<int, int>
#define m64it map<lli, lli>::iterator
#define m32it map<int, int>::iterator
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define ist insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define p_q priority_queue
#define min_p_q priority_queue<int, vt<int>, greater<int>>
using namespace std;
using namespace __gnu_pbds;
lli tmod(lli x, lli y)
{
    return (x % y + y) % y;
}
template <typename T>
void DEBUG_ARR(vt<T> a)
{
    f(i, 0, a.size()) cout << a[i] << " ";
    cout << "\n";
}
lli power(lli x, lli y) 
{
    lli res = 1;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1; 
        x = (x*x);
    }
    return res; 
}


int main()
{
    fastio;
    lli k,x;
    cin>>k>>x;
    if(500*k>=x)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 55;

int n, m;
PII rec[M];
struct Pro
{
	int s, t, c;
	bool operator<(const Pro &t) const
	{
		return s < t.s;
	}
}pro[N];

bool cmp(PII a, PII b)
{
	return a.F > b.F;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ )
	{
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		pro[i] = {s, t, c};
	}
	sort(pro, pro + n);
	
	int cnt = 0;
	for (int i = 0; i < n; i ++ )
	{
		int s = pro[i].s, t = pro[i].t, c = pro[i].c;
		bool flag = false;
		
		sort(rec, rec + cnt);
		for (int j = 0; j < cnt; j ++ )
			if (rec[j].S == c && rec[j].F <= s)
			{
				rec[j] = {t, c};
				flag = true;
				break;
			}
			else if (rec[j].S != c && rec[j].F + 1 <= s)
			{
				rec[j] = {t, c};
				flag = true;
				break;
			}
		
		if (!flag) rec[cnt ++ ] = {t, c};
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    int v[1000][100];
    rep(i,n)rep(j,m)
      cin>>v[i][j];
    pii p[100];
    rep(i,m){
      p[i].second=i+1;
      rep(j,n)
        p[i].first-=v[j][i];
    }
    sort(p,p+m);
    rep(i,m){
      cout<<p[i].second;
      if(i<m-1)cout<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3396
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
now = inpl()
now.append(0)
for _ in range(k):
    pre = now[::]
    now = [0] * (n+1)
    for j in range(n):
        a = max(0,j-pre[j])
        b = min(n,j+pre[j]+1)
        now[a] += 1
        now[b] -= 1
    x = 0
    mi = INF
    for j in range(n):
        x += now[j]
        mi = min(mi,x)
        now[j] = x
    if mi == n:
        break
print(*now[:n])

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

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    vector<int> v(11);
    v[0] = x;
    for(int i = 1; i <= 10; i++){
        v[i] = r * v[i-1] - d;
    }
    for(int i = 1; i <= 10; i++){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(9);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 3e5 + 10, INF = 1e18 + 10;

void solve() {
	int n;
    cin >> n;

    int ans = (n / 500) * 1000;
    n -= (n / 500) * 500;
    ans += (n / 5) * 5;

    cout << ans << endl;	
}	

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int N, a[200001], b[200001], cnt;
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  for(int i = N; i > 0; --i) {
    int bsum = 0;
    for(int j = i*2; j <= N; j+=i) bsum += b[j];
    if((a[i]+bsum)%2 == 1) b[i] = 1, ++cnt;
  }
  printf("%d\n", cnt);
  for(int i = 1; i <= N; ++i) {
    if(b[i] > 0) printf("%d ", i);
  }
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<set>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
ll t,x,cnt[maxn];
int main(){
   ll n,sum=0;
   cin>>n;
   for(int i=0;i<n;i++){
      scanf("%d",&x);
      cnt[x]++;
      sum+=x;
   }
   cin>>t;
   while(t--){
        int a,b;
        cin>>a>>b;
        sum+=(b-a)*cnt[a];
        cnt[b]+=cnt[a];
        cnt[a]=0;
        printf ("%lld\n",sum);

   }


}



Measured memory_bytes: 4036
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
        int ct=0;
        for(int i=a;i<=b;i++){
            if(c%i==0){
                ct++;
            }
        }
        System.out.println(ct);
    }
}    


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

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    
    for(auto &v: A)
        cin >> v;
    
    cout << (N-1 + K-2) / (K-1) << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    for(ll i = 0; i < X; i++){
        cin >> A[i];
    }
    for(int i = 0; i < Y; i++){
        cin >> B[i];
    }
    for(int i = 0; i < Z; i++){
        cin >> C[i];
    }
    vector<ll> AB = vector<ll>(0);
    for(int ai = 0; ai < min(X,K); ai++){
        for(int bi = 0; bi < min(Y,K); bi++){
            AB.push_back(A[ai] + B[bi]);
        }
    }
    sort(AB.begin(),AB.end(),greater<ll>());
    vector<ll> ABs(min(X * Y,K));
    for(int i = 0; i < min(X * Y,K); i++){
        ABs[i] = AB[i];
    }
    vector<ll> ABC = vector<ll>(0);
    for(int abi = 0; abi < ABs.size(); abi++){
        for(int ci = 0; ci < min(Z,K); ci++){
            ABC.push_back(ABs[abi] + C[ci]);
        }
    }
    sort(ABC.begin(),ABC.end(),greater<ll>());
    for(int i = 0; i < K; i++){
        cout << ABC[i] << endl;
    }

}

Measured memory_bytes: 43368
s = input()
ans = 'Yes'
for i in range(len(s)):
    if (i+1) % 2 == 1:
        if s[i] not in ['R', 'U', 'D']:
            ans = 'No'
            break
    else:
        if s[i] not in ['L', 'U', 'D']:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 9032
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  char c[3][3];
  for(int i=0;i<3;i++) {
    for(int j=0;j<3;j++) {
      cin >> c[i][j];
    }
  }
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

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

int main(){
 char a,b;
 cin>>a>>b;
 
 if(a=='H' && b=='H'){
 	cout<<"H";
 }
 if(a=='H' && b=='D'){
 	cout<<"D";
 }
 if(a=='D' && b=='H'){
 	cout<<"D";
 }
 if(a=='D' && b=='D'){
 	cout<<"H";
 }
 
 
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
area = [0, 0, w, h]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and x > area[0]:
        area[0] = x
    elif a == 2 and x < area[2]:
        area[2] = x
    elif a == 3 and y > area[1]:
        area[1] = y
    elif a == 4 and y < area[3]:
        area[3] = y
print((area[2]-area[0]) * (area[3] - area[1]) if (area[2]-area[0]) > 0 and (area[3] - area[1]) > 0 else 0)

Measured memory_bytes: 62380
#include<iostream>
#define MAX 100500

using namespace std;

int main(void){

  int n,m;
  long long int N, M[MAX],d[MAX];
  
  while(cin >> n ){

    cin >> m;

    for(int i = 0 ; i < MAX ; i++){
      M[i] = 0;
      d[i] = 0;
    }

    d[0] = 0;

    for(int i = 1 ; i < n; i++){
      cin >> N;
      d[i] += d[i-1] + N;
      //  cout << "N = " << N << " d[i] = " << d[i] << endl;
    }

    for(int i = 0 ; i < m ; i++) cin >> M[i];

    long long int sum = 0,now = 0;
    
    for(int i = 0 ; i < m ; i++){
     
      // cout << endl << "i = " << i << " now = "  << now << endl;//

      //  cout <<"now + M[i] = " << now + M[i]<<   " d[now + M[i]] = " << d[now + M[i]] << " d[now] =  " <<  d[now] << endl;//
      

      if(M[i] >= 0){
	sum += d[now + M[i]] - d[now];  
	//	cout << "! N = " << d[now + M[i]] - d[now] << endl;//
      }
      else{
	sum += d[now] - d[now + M[i]];
	//	cout << "? N = " <<  d[now] - d[now + M[i]]  << endl;//
      }

      now = now + M[i];//

    }
    cout << sum % 100000 << endl;
  }

  return 0;
}

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

int main(){
  int i,sumt=0,n,q,flag,queue[100001],time[100001],head,tail; /* キューは処理してないインデクッスを格納 */
  char name[100001][11];

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s %d",name[i],&time[i]);
    queue[i]=i;
  }

  head=0;
  tail=i;

  flag=n;/* ループ判定は処理してない数をかぞえて判断 */
  while(flag){
    
      	
     if(time[queue[head]]<=q){
       sumt+=time[queue[head]];
       flag--;
       printf("%s %d\n",name[queue[head]],sumt);
	  
     }
     else{
       time[queue[head]]-=q;
       sumt+=q;

       
       /* キュー操作(enqueue) */
       queue[tail]=queue[head];
       if(tail==100000)tail=0;
       else tail++;
	  
     }

     /* キュー操作(dequeue) */
     if(head==100000) head=0;
     else head++;
  }

  return 0;
}



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

using namespace std;

long long n, k, a[1000005], dp[1000005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i <= k; i++){
        for (int j = 0; j < n; j++){
            if (i - a[j] >= 0){
                if (!dp[i - a[j]]){
                    dp[i] = true;
                    break;
                }
            }
        }
    }
    if (dp[k]) cout << "First";
    else cout << "Second";
    return 0;
}

Measured memory_bytes: 3072
from queue import PriorityQueue
N, M = map(int, input().split())  # N件のアルバイト, M日後までに欲しい

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


pq = PriorityQueue()

for i in range(len(A)):
    pq.put(-A[i])

ans = 0

for i in range(M):
    tmp = -(pq.get())
    tmp = tmp//2
    pq.put(-tmp)

# for jobs in jobs_list:
#     for job in jobs:
#         pq.put(-job)  # min-heapであるから、マイナスにして追加する
#     if not pq.empty():  # pqに要素があるなら仕事を一つ行う
#         ans += -(pq.get())

while not pq.empty():
    ans += -pq.get()

print(ans)


Measured memory_bytes: 15292
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())



table = [False] * 1000


for a in range(1, 10):
    for b in range(1, 10):
        table[a * b] = True


n = intput()

if table[n]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    x,y=sl()
    print('<' if x < y else '=' if x == y else '>')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
char s[10],t[10];

int main(){
	scanf("%s%s",s,t);
	int cnt=0;
	for (int i=0;i<3;++i){
		if (s[i]==t[i]) ++cnt;
	}
	printf("%d",cnt);
}


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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  int numOfBlack = 0;
  int ans = 0;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> c[i][j];
      if (c[i][j] == '#') numOfBlack++;
    }
  }
  for (int s1=0; s1<(1<<H); s1++) {
    int numOfDeleteBlack;
    bitset<6> LineInfo(s1);
    int blackInLine = 0;
    vector<int> redLine(0);
    for (int bit=0; bit<H; bit++) {
      if (LineInfo.test(bit)) {
        redLine.emplace_back(bit);
        for (int row=0; row<W; row++) {
          if (c[bit][row] == '#') blackInLine++;
        }
      }
    }
    for (int s2=0; s2<(1<<W); s2++) {
      bitset<6> RowInfo(s2);
      int blackInRow = 0;
      vector<int> redRow(0);
      for (int bit=0; bit<W; bit++) {
        if (RowInfo.test(bit)) {
          redRow.emplace_back(bit);
          for (int line=0; line<H; line++) {
            if (c[line][bit] == '#') blackInRow++;
          }
        }
      }
      int blackInCommon = 0;
      for (int line : redLine) {
        for (int row : redRow) {
          if (c[line][row] == '#') blackInCommon++;
        }
      }
      numOfDeleteBlack = blackInLine + blackInRow - blackInCommon;
      if (numOfBlack - numOfDeleteBlack == K) ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644