akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> Qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> Qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n,q;
  cin >> n >> q;
  char s[n];
  cin >> s;
  vi ans(n,0);
  int cnt=0;
  REP(i,n-1) {
    if(s[i]=='A'&&s[i+1]=='C') {
      cnt++;
    }
    ans[i+1]=cnt;
  }
  REP(i,q) {
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    int a=ans[r]-ans[l];
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    answer = 0
    for i in range(max(A)):
        is_all_even = True
        for a in A:
            if a % 2 != 0:
                is_all_even = False
                break
        if is_all_even == True:
            answer += 1
            A = list(map(lambda x:int(x / 2), A))
        else:
            break
    print(answer)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
char s[120];
int mp[32];
int cnt4=0,cnt2=0,cnt1=0;
int n,m,i,j;
short check()
{
	if( (n/2*2)*(m/2*2)>cnt4 ) return 0;
	cnt4-=(n/2*2)*(m/2*2);
	cnt2+=cnt4;
	if(n%2)
	{	if(m/2*2>cnt2) return 0;
		cnt2-=m/2*2;
	}
	if(m%2)
	{	if(n/2*2>cnt2) return 0;
		cnt2-=n/2*2;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{	scanf("%s",s+1);
		for(j=1;j<=m;j++)
			mp[s[j]-'a']++;
	}
	for(i=0;i<26;i++){cnt4+=mp[i]/4*4; mp[i]%=4; cnt2+=mp[i]/2*2; mp[i]%=2; cnt1+=mp[i];}
	if(check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import javax.swing.plaf.synth.SynthProgressBarUI;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String s = readLine()[0];
		char[] cs = s.toCharArray();
		ArrayList<String> css = new ArrayList<String>();
		StringBuilder now = new StringBuilder();
		css.add(new StringBuilder().append(cs[0]).toString());
		for(int ci = 1; ci<cs.length; ci++) {
			now.append(cs[ci]);
			if(!css.get(css.size()-1).equals(now.toString())) {
				css.add(now.toString());
				now = new StringBuilder();
			}
		}
		print(css.size());
		
		/*
		for(int N = cs.length; N>=1; N--) {
			int[][] cc = getCombinations(cs.length,N);
			for(int i=0;i<cc.length;i++) {
				ArrayList<String> ss = divArrayToArrayLength(cs,cc[i]);
				if(isOK(ss)) {
					print(N);
					return;
				}
			}
		}*/
	}
	
	//functions here
	//note that all methods should be STATIC
	private static ArrayList<String> divArrayToArrayLength(char[] cs, int[] lengths){
		ArrayList<String> res = new ArrayList<String>();
		int ci = 0;
		for(int li = 0; li<lengths.length;li++) {
			StringBuilder sb = new StringBuilder();
			for(int ccount=0;ccount<lengths[li];ccount++) {
				sb.append(cs[ci++]);
			}
			res.add(sb.toString());
		}
		return res;
	}
	
	private static int[][] getCombinations(int all, int section) {
		if(all<section) {return new int[0][0];}
		if(section==1) {return new int[][] {{all}};}
		ArrayList<Integer[]> is = new ArrayList<>();
		for(int k=1;k<=all-section+1;k++) {
			int[][] isl = getCombinations(all-k,section-1);
			for(int j=0;j<isl.length;j++) {
				Integer[] ist = new Integer[section];
				ist[0] = k;
				for(int i=0;i<isl[j].length;i++) {
					ist[i+1] = isl[j][i];
				}
				is.add(ist);
			}
		}
		int[][] res = new int[is.size()][section];
		for(int i=0;i<is.size();i++) {
			for(int j=0;j<section;j++) {
				res[i][j] = is.get(i)[j];
			}
		}
		return res;
	}
	private static boolean isOK(ArrayList<String> ss) {
		for(int i=0;i<ss.size()-1;i++) {
			if(ss.get(i).equals(ss.get(i+1))) {
				return false;
			}
		}
		return true;
	}
	
	private static int isIn(Object needle, Object[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}

	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

Measured memory_bytes: 52632
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

while True:
    n = fp.readline()[:-1]
    if not n:
        break

    c_joi = 0
    c_ioi = 0
    for i in xrange(len(n)-2):
        if n[i:i+3] == "JOI":
            c_joi += 1
        if n[i:i+3] == "IOI":
            c_ioi += 1
    print c_joi
    print c_ioi

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

using namespace std;

struct Node{
  int key;
  Node *next;
  Node *prev;
};

Node *nil;

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deletekey(int key){
  deleteNode(listSearch(key));
}

void print(){
  Node *cur = nil->next;
  int f=0;
  while(1){
    if(cur == nil) break;
    if(f) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
    f=1;
  }
  printf("\n");
}

int main(){
  int n,a,np=0,size=0,nd=0;
  char c[20];
  scanf("%d",&n);
  init();
  for(int i=0;i<n;i++){
    scanf("%s%d",c,&a);
    if(c[0]=='i'){
      insert(a);
      np++;
      size++;
    }
    else if(c[0]=='d'){
      if(strlen(c) > 6){
	if(c[6]=='F') deleteFirst();
	else if(c[6]=='L') deleteLast();
      }
      else{
	deletekey(a);
	nd++;
      }
      size--;
    }
  }
  print();
  return 0;
}
  



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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int h, w, c;
vvi panel;
vvi initPanel;
vvb visited;
vi change;

bool in(int i, int j){
	return 0 <= i && i < h && 0 <= j && j < w;
}

int CountDfs(int i, int j){
	visited[i][j] = true;
	int sum = 1;
	int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
	for (int k = 0; k < 4; k++) {
		int ni = i + dy[k], nj = j + dx[k];
		if (in(ni, nj) && !visited[ni][nj] && panel[ni][nj] == c)
			sum += CountDfs(ni, nj);
	}
	return sum;
}

int CountBond(){
	int ret = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!visited[i][j] && panel[i][j] == c)
				ret = max(ret, CountDfs(i, j));
		}
	}
	return ret;
}

void Change(int i, int j, int color, int prev){
	panel[i][j] = color;
	int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
	for (int k = 0; k < 4; k++) {
		int ni = i + dy[k], nj = j + dx[k];
		if (in(ni, nj) && panel[ni][nj] == prev)
			Change(ni, nj, color, prev);
	}
}

int apply(){
	for (int i = 0; i < 5; i++) {
		if (change[i] != panel[0][0])
			Change(0, 0, change[i], panel[0][0]);
	}

	return CountBond();
}

int calc(){
	int ret = 0;
	int maxCount = pow(6, 5);

	panel = vvi(h, vi(w, 0));
	change = vi(5);

	for (int loop = 0; loop < maxCount; loop++) {
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				panel[i][j] = initPanel[i][j];

		visited = vvb(h, vb(w, false));
		int n = loop;
		for (int i = 0; i < 4; i++) {
			change[i] = (n % 6) + 1;
			n /= 6;
		}
		change[4] = c;
		ret = max(ret, apply());
	}
	return ret;
}

int main(){
	while (cin >> h >> w >> c , !(h == 0 && w == 0 && c == 0)) {
		initPanel = vvi(h, vi(w, 0));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> initPanel[i][j];
			}
		}
		cout << calc() << endl;
	}
}

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

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int count = s.length();
    for(int i = 0; i < s.length(); i++)
        if(s[i] == t[i])
            count--;

    cout << count << endl;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll n,m;cin>>n>>m;
	ll x=pow(2,m);
	ll ans=x*(1800*m+100*n);

	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(str,S);
  ll count = 0;
  REP(i,S.size()/2){
    if(S.at(i) != S.at(S.size() - 1 - i))
       count++;
  }
  OUT(count);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  if (A >= 13)
  {
    cout << B << endl;
  }
  else if (A >= 6)
  {
    cout << B / 2 << endl;
  }
  else
  {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int s[4];
    for (int i = 0; i < 4; ++i) {
        cin >> s[i];
    }
    int x = s[2] - s[0];
    int y = s[3] - s[1];
    string ret("");
    ret += string(x, 'R');
    ret += string(y, 'U');
    ret += string(x, 'L');
    ret += string(y, 'D');

    ret += "D";
    ret += string(x + 1, 'R');
    ret += string(y + 1, 'U');
    ret += "L";
    ret += "U";
    ret += string(x + 1, 'L');
    ret += string(y + 1, 'D');
    ret += "R";

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
N, M, Q = map(int, sys.stdin.readline().rstrip().split())

#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h, w, a):
    da = [[0] * w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1, w):
        da[0][i] = da[0][i - 1] + a[0][i]
    for i in range(1, h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i - 1][j] + cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p, q, x, y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y] - da[x][q - 1]
    if q == 0:
        return da[x][y] - da[p - 1][y]
    return da[x][y] - da[p - 1][y] - da[x][q - 1] + da[p - 1][q - 1]

a = [[0] * N for _ in range(N)]

for _ in range(M):
    l, r = map(int, sys.stdin.readline().rstrip().split())
    a[l - 1][r - 1] += 1

da = da_generate(N, N, a)

for _ in range(Q):
    p, q = map(int, sys.stdin.readline().rstrip().split())
    p -= 1
    q -= 1
    print(da_calc(p, p, q, q))

Measured memory_bytes: 57564
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

struct edge {
    ll to;
    ll cap;
    ll rev;
};

#define MAX_V 50000

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(ll from,ll to,ll cap) {
    G[from].push_back((edge){to,cap,(ll)G[to].size()});
    G[to].push_back((edge){from,0,(ll)G[from].size() - 1});
}

ll dfs(ll v,ll t,ll f) {
    if(v == t) return f;
    used[v] = true;
    for(auto &e : G[v]) {
        if(!used[e.to] && e.cap > 0) {
            ll d = dfs(e.to,t,min(e.cap,f));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(ll s,ll t) {
    ll flow = 0;
    for(;;) {
        fill(used,used+MAX_V,false);
        ll f = dfs(s,t,1e18);
        if(f == 0) break;
        flow += f;
    }
    return flow;
}
ll h,w;
char a[200][200];

ll id(ll i,ll j) {
    return i * w + j;
}

int main() {
    cin >> h >> w;
    rep(i,h)cin >> a[i];

    rep(i,h)rep(j,w) {
        if(a[i][j] == '.')continue;

        for(ll k = i + 1;k < h;k++) {
            if(i == k)continue;
            if(a[k][j] == '.')continue;

            add_edge(id(k,j),id(i,j),1e18);
            add_edge(id(i,j),id(k,j),1e18);
            break;
        }
        for(ll k = j + 1;k < w;k++) {
            if(j == k)continue;
            if(a[i][k] == '.')continue;

            add_edge(id(i,k) + h * w,id(i,j) + h * w,1e18);
            add_edge(id(i,j) + h * w,id(i,k) + h * w,1e18);
            break;
        }
    }

    rep(i,h)rep(j,w) {
        if(a[i][j] == '.')continue;
        if(a[i][j] == 'S' || a[i][j] == 'T') {
            add_edge(id(i,j),id(i,j) + h * w,1e18);
            add_edge(id(i,j) + h * w,id(i,j),1e18);
            continue;
        }
        add_edge(id(i,j),id(i,j) + h * w,1);
        add_edge(id(i,j) + h * w,id(i,j),1);
    }

    ll s,t,si,sj,ti,tj;
    rep(i,h) rep(j,w) {
        if(a[i][j] == 'S') {
            s = id(i,j);
            si = i;
            sj = j;
        }
        if(a[i][j] == 'T') {
            t = id(i,j);
            ti = i;
            tj = j;
        }
    }

    if(si == ti || sj == tj){
        cout << -1 << endl;
    }else{
        cout << max_flow(s,t) << endl;
    }
    return 0;
}

Measured memory_bytes: 6016
N, K = map(int, input().split())
S = list(input())
S_2 = [S[0]]
ans = 0

if N == 1:
    print(0)
else:
    for i in range(N - 1):
        if S[i+1] != S_2[-1]:
            S_2.append(S[i+1])
        if S[i+1] == S[i]:
            ans += 1
    
    num_lr = len(S_2)   # L集合・R集合の数の合計
    num = num_lr // 2   # 便宜的に左端がL集合としたとき、R集合だけを操作できる回数
    
    if num_lr == 1:
        ans = ans
    elif num_lr % 2 == 0:
        if num > K:
            ans += (K * 2)
        elif num <= K:
            ans += ((num * 2) - 1)
    elif num_lr % 2 == 1:
        if num >= K:
            ans += (K * 2)
        elif num < K:
            ans += (num * 2)
    
    print(ans)

Measured memory_bytes: 4772
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int N,A,B;

int main(){
    cin>>N>>A>>B;
    out(min(N*A,B));
}


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

int main(){
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 4; i++){
		if (S.at(i) == '+')
			ans++;
		if (S.at(i) == '-')
			ans--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], l;
int32_t main(){_

   cin>>n>>l;

   int sum = 0;
   for (int i = 1; i <= n; ++i)
   {
      a[i] = l + i - 1;
      sum += a[i];
   }

   int ans = inf, vals = 0;
   for (int i = 1; i <= n; ++i)
   {
      int sum2 = sum - a[i];
      if (ans > abs(sum - sum2)){
         ans = abs(sum - sum2);
         vals = sum2;
      }
   }
   
   cout<<vals;  

   return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> x(N),y(N);
    for (int i=0; i<N; i++) {
        cin >> x[i] >> y[i];
    }
    
    map<pair<long long, long long>, int> mp;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            if (mp.find(make_pair(x[i]-x[j], y[i]-y[j])) != mp.end()) {
                mp[make_pair(x[i]-x[j], y[i]-y[j])]++;
            }
            else{
                mp.emplace(make_pair(x[i]-x[j], y[i]-y[j]), 1);
            }
            
            if (mp.find(make_pair(x[j]-x[i], y[j]-y[i])) != mp.end()){
                mp[make_pair(x[j]-x[i], y[j]-y[i])]++;
            }
            else{
                mp.emplace(make_pair(x[j]-x[i], y[j]-y[i]), 1);
            }
        }
    }
    
    int max=0;
    auto begin = mp.begin(), end = mp.end();
    for (auto itr = begin; itr != end; itr++) {
        if(itr->second > max){
            max = itr->second;
        }
    }
    int ans=N-max;
    cout << ans << endl;
}


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

int main(){

  int N;
  string S;
  cin >> N;
  cin >> S;
  
  
  if(N%2==0){
   for(int i=0;i<N/2;i++){
     if(S.at(i)==S.at(N/2+i)){
        continue;       
     }
        
        else{
            cout << "No" << endl;
          exit(0);
        }
   }
   }
        
   else{
       cout << "No" << endl;
     exit(0);
   }
  
    
    cout << "Yes" << endl;
    
  }
 


Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int i, j, d, total = 0;
    for(i=1; i<=n; i++)
    {
        d = 0;
        for(j=1; j<=i; j+=2)
        {
            if(i%j == 0)    d++;
        }
        if(d == 8)  total++;
    }
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    long long n, k;
    cin >> n;
    k = n - 1;
    int m = sqrt(n);
    for (int i = 2; i <= m; i++) {
        if (n % i==0 && i + n / i - 2 < k)  k = i + n / i - 2;
    }
    cout << k<< endl;
    return 0;
}



Measured memory_bytes: 256
def concentration(water, suger):
  return 100 * suger / (water + suger)

WATER_A, WATER_B, SUGER_C, SUGER_D, MELT_PER_100, LIMIT = map(int, input().split())

WATER_A *= 100
WATER_B *= 100
# 砂糖の溶解率の上限
MELT_PERCENT_LIMIT = concentration(100, MELT_PER_100)

wa = wb = sc = sd = 0

water_set = set()
while wa * WATER_A <= LIMIT:
  while wb * WATER_B <= LIMIT:
    water = wa * WATER_A + wb * WATER_B
    if water <= LIMIT:
      water_set.add(water)
    wb += 1
  wb = 0
  wa += 1

suger_set = set()
while sc * SUGER_C <= LIMIT:
  while sd * SUGER_D <= LIMIT:
    suger = sc * SUGER_C + sd * SUGER_D
    if suger <= LIMIT:
      suger_set.add(suger)
    sd += 1
  sd = 0
  sc += 1

ans_suger_water = 0
ans_suger = 0
# 最大溶解率を保持するための変数
max_concentration = 0

for water in water_set:
  for suger in suger_set:
    # 砂糖水の量が0より大きく制限量以下以外の場合は次のループへ
    if not (0 < water + suger <= LIMIT):
      continue
    # 砂糖濃度計算
    suger_precent = concentration(water, suger)
    # 砂糖濃度が最高を更新かつ限界濃度を超えていなければ答えを更新
    if max_concentration <= suger_precent <= MELT_PERCENT_LIMIT:
      max_concentration = suger_precent
      ans_suger_water = water + suger
      ans_suger = suger

print(ans_suger_water, ans_suger)

Measured memory_bytes: 3188
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int ans = Reader.ReadLine().Count(a => a == '1');
        Console.WriteLine(ans);
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





101


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

int main() {
	ll k = 0;
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		k ^= a[i];
	}
	rep(i, n) {
		ll ki = k ^ a[i];
		cout << ki <<" ";
	}
  cout<<endl;
}

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

using namespace std;

int main() {
    string a;
    cin >> a;

    int n = a.size();

    int ans = 0;

    for (int i = 0; i < n; i++) {
        ans += a[i] - '0';
    }

    ans = max(ans, (a[0] - '0' - 1) + 9 * (n - 1));

    cout << ans << endl;
}


Measured memory_bytes: 888
import core.stdc.stdio;
import std.math;
import std.algorithm;
import std.typecons;
import std.stdio;

void main(){
	int n;
	scanf("%d",&n);
	long[] x=new long[n],y=new long[n];
	foreach(i;0..n)
		scanf("%lld%lld",&x[i],&y[i]);
	alias Tuple!(long,"x",long,"y",int,"k") p;
	p[] ps = new p[n-1];
	foreach(i;0..n){
		int c;
		int u1;
		int u2;
		foreach(j;0..n)
			if(j<i){
				if(y[j]>=y[i]){
					ps[c++]=p(x[j]-x[i],y[j]-y[i],0);
					u1++;
				}else
					ps[c++]=p(x[i]-x[j],y[i]-y[j],1);
			}else if(j>i){
				if(y[j]>=y[i]){
					ps[c++]=p(x[j]-x[i],y[j]-y[i],2);
					u2++;
				}else
					ps[c++]=p(x[i]-x[j],y[i]-y[j],3);
			}
		sort!((a,b)=>a.x*b.y>a.y*b.x)(ps);
		if((u1==0||u1==i)&&(u2==0||u2==(n-i-1)))
			continue;
		bool ok=false;
		foreach(v;ps){
			if(v.k==0)
				u1--;
			else if(v.k==1)
				u1++;
			else if(v.k==2)
				u2--;
			else if(v.k==3)
				u2++;
			else
				assert(false);
			if((u1==0||u1==i)&&(u2==0||u2==(n-i-1))){
				ok=true;
				break;
			}
		}
		if(!ok){
			printf("Impossible\n");
			return;
		}
	}
	printf("Possible\n");
}

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

int main(){
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;

  int ans;
  if (a < 0 && b < 0) {
    ans = (b - a) * c;
  } else if (a < 0 && b >= 0) {
    ans = (0 - a) * c + d + (b - 0) * e;
  } else if (a > 0) {
    ans = (b - a) * e;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3080
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int dx[2][6]={{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};
const int dy[6]={0,-1,-1,0,1,1};
int dis[100][100];
bool land[100][100];

int main(){
	for(int m,n;scanf("%d%d",&n,&m),n;){
		for(int i=0;i<m;i++)for(int j=0;j<n;j++)	land[i][j]=false,dis[i][j]=1<<30;

		int s;	scanf("%d",&s);
		for(int i=0;i<s;i++){
			int px,py;	scanf("%d%d",&px,&py);
			px--,py--;
			land[py][px]=true;

			dis[py][px]=0;
			queue<pii> qu;	qu.push(mp(py,px));
			while(!qu.empty()){
				pii a=qu.front();	qu.pop();
				int y=a.first,x=a.second;
				for(int k=0;k<6;k++){
					int yy=y+dy[k],xx=x+dx[y%2][k];
					if(0<=yy && yy<m && 0<=xx && xx<n){
						if(dis[y][x]+1<dis[yy][xx]){
							qu.push(mp(yy,xx));
							dis[yy][xx]=dis[y][x]+1;
						}
					}
				}
			}
		}

		int t,ans=0;	scanf("%d",&t);
		while(t--){
			static int tmp[100][100];
			for(int i=0;i<m;i++)for(int j=0;j<n;j++)	tmp[i][j]=1<<30;

			int px,py;	scanf("%d%d",&px,&py);
			px--,py--;
			if(dis[py][px]==0)	continue;

			int cnt=0;
			tmp[py][px]=0;
			queue<pii> qu;	qu.push(mp(py,px));
			while(!qu.empty()){
				pii a=qu.front();	qu.pop();
				int y=a.first,x=a.second;
				cnt++;
				for(int k=0;k<6;k++){
					int yy=y+dy[k],xx=x+dx[y%2][k];
					if(0<=yy && yy<m && 0<=xx && xx<n){
						if(tmp[y][x]+1<tmp[yy][xx] && tmp[y][x]+1<dis[yy][xx]){
							qu.push(mp(yy,xx));
							tmp[yy][xx]=tmp[y][x]+1;
						}
					}
				}
			}

			ans=max(ans,cnt);
		}

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

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N,K;
  cin>>N>>K;

  vector<int> a(N);

  rep(i,N){
    int aa;
    cin>>aa;
    a[i]=min(K,aa);
  }

  SORT(a);

  int ok = -1; // 最初のindexより1つ前 ngとokは場合により入れ替え
  int ng = N; // 最後のindexより1つあと
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;

    int MAX=5001;
    bool dp[N+1][MAX+1]={}; //前からj番目までのカードの取りうる合計値k が存在するかどうかbool
    dp[0][0]=true;


    rep(j,N){
      rep(k,MAX+1){
        if(dp[j][k]){
          dp[j+1][k]=true;
          if(j!=mid) dp[j+1][min(MAX,k+a[j])]=true;
        }
      }
    }

    bool iran=true;
    reps(j,max(0,K-a[mid]),K){
      if(dp[N][j]) iran=false;
    }

    if(iran) ok = mid;
    else ng = mid;
  }

  ok++;

  cout << ok <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 24704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int p = scan.nextInt();
		int q = scan.nextInt();
		int r = scan.nextInt();

		if(p<=q) {
			if(q<=r) System.out.println(p+q);
			else System.out.println(p+r);
		}
		else {
			if(p<=r) System.out.println(p+q);
			else System.out.println(q+r);
		}


	}
}

Measured memory_bytes: 23252
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    s = [input() for i in range(n)]
    print('AC x {}'.format(s.count('AC')))
    print('WA x {}'.format(s.count('WA')))
    print('TLE x {}'.format(s.count('TLE')))
    print('RE x {}'.format(s.count('RE')))
    return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 83516
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if (a < b && b < c)
        printf("Yes\n", a, b, c);
    else if (a >= b || a >= c || b >= c)
        printf("No\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 5e3+1;
const int mod = 1e9+7;
ll dp1[upperlimit][upperlimit];
int main() {
	dp1[0][0]=1;
	int n;
	string s;
	cin >> n >> s;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			if(j!=n) dp1[i][j]=dp1[i-1][j+1];
			if(j) dp1[i][j]+=dp1[i-1][j-1]*2ll;
			else dp1[i][j]+=dp1[i-1][j];
			dp1[i][j]%=mod;
		}
	}
	ll ans = dp1[n][int(s.size())];
	ans*=powmod(2,mod-1-int(s.size()),mod);ans%=mod;
	cout << ans;
	return 0;
}

Measured memory_bytes: 195584
N = int(input())
a = 0  # Aで終了
b = 0  # Bで開始
ab = 0 # Aで終了, Bで開始
ans = 0
for _ in range(N):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B':
        b += 1
        if s[-1] == 'A':
            a += 1
            ab += 1
    elif s[-1] == 'A':
        a += 1
if a == b == ab:
    if a == 0:
        print(ans)
    else:
        print(ans + a - 1)
else:
    print(ans + min(a, b))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

int N;
vector<int> h;
vector<int> dp;

int main(){
        cin >> N;
        h.resize(N);
        dp.resize(N);

        FOR(i,0,N) cin >> h[i];
        dp[0] = 0;
        dp[1] = abs(h[1] - h[0]);
        FOR(i,2,N){
                dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
        }
        cout << dp[N-1] << endl;
        //debug
//        FOR(i,0,N){
//                cout << dp[i] << " ";
//        }
//        cout << endl;
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void) {
  int m,f,r;
  int sum;
  while(cin >> m >> f >> r && (m != -1 || f != -1 || r != -1)) {
    sum = m + f;
    if(m == -1 || f == -1 || sum < 30)
      cout << 'F' << endl;
    else if(sum >= 80)
      cout << 'A' << endl;
    else if(sum >= 65 && sum < 80)
      cout << 'B' << endl;
    else if(sum >= 50 && sum < 65)
      cout << 'C' << endl;
    else {
      if(r >= 50)
        cout << 'C' << endl;
      else
        cout << 'D' << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3056
n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

B = [0] * (n+1)

for i in range(m):
    B[A[i][0]] += 1
    B[A[i][1]] += 1

no = 0
for i in range(1, n+1):
    if B[i] % 2 == 1:
        no = 1
        break

if no == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61016
n = gets.to_i
balls = []
n.times { balls << gets.split.map(&:to_i) }
inclination_memo = Hash.new(0)

balls.each_with_index do |(x, y), i|
  balls.each_with_index do |(x2, y2), i2|
    next if i == i2
    inclination_memo[[x2 - x, y2 - y]] += 1
  end
end

puts n - (inclination_memo.values.max || 0)


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        ans-=(i%2==0&&s[i]=='p');
        ans+=(i%2==1&&s[i]=='g');
    }
    out(ans);
}

Measured memory_bytes: 3828
# AtCoder Beginner Contest 148
# F - Playing Tag on Tree
# https://atcoder.jp/contests/abc148/tasks/abc148_f
from collections import deque

import sys
input = sys.stdin.readline
N, U, V = map(int, input().split())
U -= 1
V -= 1
G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

INF = 10**10

T = [INF]*N
T[U] = 0
A = [INF]*N
A[V] = 0


def bfs(v, dist):
    q = deque()
    q.append(v)
    k = 0
    visited = [0]*N
    while q:
        v = q.popleft()
        visited[v] = 1
        k = dist[v]

        for u in G[v]:
            if visited[u]:
                continue
            q.append(u)
            dist[u] = k+1


bfs(U, T)
bfs(V, A)

if A[U] <= 1:
    print(0)
    exit()

farthest = 0
node = -1
for i, (t, a) in enumerate(zip(T, A)):
    if t < a and farthest < a:
        farthest = a
        node = i

print(farthest-1)


Measured memory_bytes: 30088
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            int n = Integer.parseInt(line);
            int money = 100000;
            for(int i=0;i<n;i++){
            	money *= 1.05;
            	String temp = money + "";
            	int len = temp.length();
            	if((!temp.substring(len-1, len).equals("0")) || (!temp.substring(len-2, len-1).equals("0"))
            			|| ((!temp.substring(len-3, len-2).equals("0")))){
            		money = ((money / 1000) + 1) * 1000;
            	}
            	//money = money % 1000 == 0 ? money : ((money / 1000) + 1) * 1000;
            }
            System.out.println(money);
    }
}

Measured memory_bytes: 24028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

ll X;

int main() {
    cin >> X;

    ll now = 100;
    ll ans = 0;
    while (now < X) {
        now = (ll)((double)now * 1.01);
        ans++;
    }

    cout << ans << endl;


    
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	double a;
	scanf("%lf",&a);
	a=a/3.0;
	printf("%f",a*a*a);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    string s;
    cin>>n;
    cin>>s;
    
    if(s.substr(0,n/2)==s.substr(n/2,n)){
        std::cout <<"Yes"<< std::endl;
    }else{
        std::cout <<"No"<< std::endl;
    }
    
    
    
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<n-2;){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      count++;
      i+=3;
    }
    else i++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

ll bin_pow(ll base,ll deg)
{
    if (deg==0)
        return 1;
    ll t=bin_pow(base,deg/2);
    if (deg&1)
        return (((t*t)%mod1)*base)%mod1;
    else
        return (t*t)%mod1;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    vector <ll> a(n);
    rep(i,n)
    cin>>a[i];
    vector <ll> aa=a;
    map <int,int> m;
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        for (int j=2;j*j<=aa[i];j++)
        {
            if (aa[i]%j==0)
            {
                int cnt=0;
                while (aa[i]%j==0)
                    aa[i]/=j,cnt++;
                m[j]=max(m[j],cnt);
            }
        }
        if (aa[i])
            m[aa[i]]=max(m[aa[i]],1);
    }
    ll prod=1;
    for (auto to:m)
    {
        prod*=bin_pow(to.first,to.se);
        prod%=mod1;
    }
    for (int i=0;i<n;i++)
    {
        ans+=(prod*bin_pow(a[i],mod1-2))%mod1;
        ans%=mod1;
    }
    cout<<ans;


}

Measured memory_bytes: 896
r=lambda x:p[x]>=0and r(p[x])or x
(n,m,k),*t=[map(int,t.split())for t in open(0)]
p,s=[-1]*-~n,[-1]*-~n
for i,(a,b)in enumerate(t):
  x,y=r(a),r(b)
  if(x!=y)*m>i:
    if x>y:x,y=y,x
    p[x]+=p[y]
    p[y]=x
  if r(a)==r(b)or i<m:
    s[a]-=1
    s[b]-=1
for i in range(n+1):s[i]-=p[r(i)]
print(*s[1:])

Measured memory_bytes: 96856
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    sc.close();

    StringBuffer ans = new StringBuffer();
    for (int i = 0; i < n; i++) {
      ans.append(S.charAt(i));
      ans.append(T.charAt(i));
    }

    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 21844
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:i64
    }

    let mut cnt = 0;
    for i in 1..n+1 {
        let s = format!("{}",i);
        if s.len() % 2 != 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)
    // {
       
    // }
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll mod=1e9+7;
    ll sum1=0;
    ll sum2=0;
    for(ll i=0;i<=n;i++)
    {
        sum1+=i;
    }
    sum2=sum1;
    for(ll i=n+1,j=0,p=n;i>=k;i--,j++,p--)
    {
        ll temp=sum2-sum1+1;
        ans=(ans%mod+temp%mod)%mod;
        sum2-=j;
        sum1-=p;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 102;
ll n,m,x,a,ans=INF;

int main(){
	cin>>n>>m>>x;
	ll h=0,mi=0;
	FOR(i,0,m){
		cin>>a;
		if(a>x)mi++;
		else h++;
	}
	cout<<min(mi,h)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>


using namespace std;
int main() {
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long count = 0;
    for(int i = 0; i < N; i++){
        if(i != N - 1){
            count += A[i] / 2;
            A[i] = A[i] % 2;
            if(A[i] == 1 && A[i + 1] > 0){
                count += 1;
                A[i + 1] -= 1;
            }
        }else{
            count += A[i] / 2;
            A[i] = A[i] % 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

li = []
for i in range(5):
    li.append(II())

sum_ = 0
li_mod = []
for i in li:
    if i%10 == 0:
        sum_ += i
    else:
        sum_ += ((i//10)+1)*10
        li_mod.append(10-i%10)
if li_mod:
    sum_ -= max(li_mod)

print(sum_)


Measured memory_bytes: 3064
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

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

    int ans = k;
    for (int i = 1; i < n; i++) {
        ans *= (k - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256