akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[4] = {};
int main(){
	REP(i, 2) {
		int b;  scanf("%d", &b);
		a[b] = true;
	}
	FOR(i, 1, 4){
		if(!a[i]) printf("%d\n", i);
	}
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
p=list(map(int,input().split()))

arr=np.array(p)
temp=np.arange(1,n+1)
zeroplace=arr-temp
a=np.nonzero(zeroplace==0)[0].tolist()

cnt=len(a)
for i in range(1,len(a)):
    if a[i-1]+1==a[i]:
        a[i]-=1
        cnt-=1
print(cnt)

Measured memory_bytes: 23504
def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
n = int(input())
a = list(map(int,input().split()))
right,left = [0]*n,[0]*n
left[0],right[n-1] = a[0],a[n-1]
for i in range(1,n):
    left[i] = gcd(left[i-1],a[i])
for i in range(n-2,-1,-1):
    right[i] = gcd(right[i+1],a[i])
ans = max(left[-2],right[1])
for i in range(1,n-1):
    ans = max(ans,gcd(right[i+1],left[i-1]))
print(ans)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: i32 = read();
    let bef: i32 = n/100;
    let aft: i32 = n%100;
    if bef == 0 || aft == 0 {
	if bef != 0 && bef <= 12{
	    println!("MMYY");
	}else if aft != 0 && aft <= 12{
	    println!("YYMM");
	}else{
	    println!("NA");
	}
    }else if bef <= 12 && aft <= 12 {
	println!("AMBIGUOUS");
    }else if bef <= 12 {
	println!("MMYY");
    }else if aft <= 12{
	println!("YYMM");
    }else {
	println!("NA");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int gcd(int x, int y) {
	int tmp;
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}
	while (y > 0) {
		tmp = x % y;
		x = y;
		y = tmp;
	}
		
	return x;
}

int main(void) {
	int x, y;
	
	scanf("%d %d", &x, &y);
	printf("%d\n", gcd(x, y));
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
    int N, Q;
    while(cin >> N >> Q, N) {
        vector<tuple<string, int, int>> v(N);
        for(int i=0; i<N; ++i) {
            string name;
            int eby, wy;
            cin >> name >> eby >> wy;
            v[i] = make_tuple(name, wy - eby + 1, wy);
        }
        sort(v.begin(), v.end(), [](auto const& t1, auto const& t2) {
            return get<1>(t1) < get<1>(t2);
        });

        for(int i=0; i<Q; ++i) {
            int year;
            cin >> year;
            bool finded = false;
            for(int i=0; i<v.size(); ++i) {
                if(get<1>(v[i]) <= year && year <= get<2>(v[i])) {
                    cout << get<0>(v[i]) << " " << year - get<1>(v[i]) + 1 << endl;
                    finded = true;
                    break;
                }
            }
            if(!finded) {
                cout << "Unknown" << endl;
            }
        }
    }
}


Measured memory_bytes: 3208
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

int main() {

	int a, b, t;

	cin >> a >> b >> t;

	int ans = 0;
	int aa = 1;
	while (t + 0.5 > a*aa) {

		aa++;
		ans += b;
	}
	
	cout << ans << endl;

	return 0;
}

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

long gcd(long a, long b){
    if(a<b){
        long t=a;
        a=b;
        b=t;
    }
    while(b!=0){
        long r=a%b;
        a=b;
        b=r;
    }
    return a;
}

bool solve(){
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b>d || a<b){
        return false;
    }
    {
        long g=gcd(d-b, b);
        if(g+c<b){
            return false;
        }
    }
    {
        long q = a/b;
        if(q>=2){
            a-=(q-1)*b;
        }
    }
    {
        long q = d/b;
        if(q>=2){
            d-=(q-1)*b;
        }
    }
    for(long i=0; i<10; i++){
        a-=b;
        if(a<0){
            return false;
        }
        if(a<=c){
            a+=d;
        }
    }
    return true;
}

int main(void){
    long t;
    cin >> t;
    for(long i=0; i<t; i++){
        bool b=solve();
        cout << (b ? "Yes" : "No" ) << "\n";
    }
    return 0;
}


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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    double W, H, x, y;
    int c = 0;
    cin >> W >> H >> x >> y;
    if ((W / 2.0 == x) && (H / 2.0 == y)) c = 1;

    cout << setprecision(5) << (W * H / 2.0) << " " << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1; 
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,x,y,f[2005],sum[2005],sum2[2005],min1;
int top,nex[4005],to[4005],fir[2005];
char s[2005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void ss(int u,int v){
	if(s[v]=='1'){
		sum[v]=1;
		sum2[v]=1;
	}
	else{
		sum[v]=0;
		sum2[v]=0;
	}
	int max1=0,max2=0,sum1=0;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u){
			ss(v,to[top1]);
			if(sum2[to[top1]]>max1){
				max1=sum2[to[top1]];
				max2=f[to[top1]];
			}
			sum1+=sum2[to[top1]];
			sum[v]+=sum[to[top1]];
			sum2[v]+=sum2[to[top1]]+sum[to[top1]];	
		}
	sum1-=max1;
	if(max1-(max2<<1)>sum1)
		f[v]=max2+sum1;
	else
		f[v]=((sum2[v]-sum[v])>>1);
}
int main(){
	n=read();
	scanf("%s",s+1);
	for(i=1;i<n;i++){
		x=read();y=read();
		lj(x,y);
		lj(y,x);
	}
	min1=n*n+1;
	for(i=1;i<=n;i++){
		ss(i,i);
		if((f[i]<<1)==(sum2[i]-sum[i]))
			min1=min(min1,f[i]);
	}
	if(min1==n*n+1)
		pus(-1,2);
	else
		pus(min1,2);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

ll a[N],b[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
//    cin>>t;
    while(t--){
        ll n,x;
        cin>>n;

        for(int i=1;i<=n;++i){
            cin>>x;
            b[i]=x;
            a[x]++;
        }
        ll res=0ll;
        for(int i=1;i<=N;++i){
            if(a[i]!=0){
                res+=(a[i]*(a[i]-1))/2ll;
            }
        }

        for(int i=1;i<=n;++i){
            ll r= res- (a[b[i]]*(a[b[i]]-1))/2;
            if(a[b[i]]-1 !=0)r+= ((a[b[i]]-1)*(a[b[i]]-2))/2ll;
            printf("%lld\n",r);
        }



        //printf("Case %d: ",++te);
    }
    return 0;
}




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

int main(){
	int n;
	while( cin >> n ){
		int i=0;
		for( ; i<10; i++ ){
			if( n & (1<<i) ){
				cout << (1<<i);
				i++;
				break;
			}
		}
		for( ; i<10; i++ ){
			if( n & (1<<i) ){
				cout << " " << (1<<i);
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<vector>
#include<iostream>
#include<algorithm>
#include<tuple>
#include<string>
#include<bits/stdc++.h>
using namespace std;
string s;
vector<string> n;

void printVec(vector<string> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}
 void solve(){
    int A,B,C,K,mhigh,ans,D;
    ans=0;
    cin>>A>>B>>C>>K;
    mhigh=max(A,max(B,C));
    D=mhigh;
    mhigh*=pow(2,K);
    ans=A+B+C+mhigh-D;
    cout<<ans<<endl;
}

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

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
#define INF (1<<28)
typedef pair<int,int> P;
struct state{
  int ay,ax,by,bx,f,cost;
  bool operator < (const state &p)const{return cost>p.cost;}
};
int W,H;
int t[60][30];
vector<P> A,B;

void init(){
  A.clear();B.clear();
}

int dist(int a,int b,int c,int d){return abs(a-c)+abs(b-d);}
int d[60][30][60][30][2];
int solve(){
  fill((int*)d,(int*)(d+60),INF);
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  state s;
  priority_queue<state> Q;
  for(int i=0;i<(int)A.size();i++){
    s.ay=A[i].second;
    s.ax=A[i].first;
    s.by=A[i].second;
    s.bx=A[i].first;
    s.cost=0;
    for(int j=0;j<2;j++){
      s.f=j;
      d[s.ay][s.ax][s.by][s.bx][s.f]=0;
      Q.push(s);
    }
  }
  while(!Q.empty()){
    s=Q.top();Q.pop();
    if(s.cost>d[s.ay][s.ax][s.by][s.bx][s.f])continue;
    if(t[s.ay][s.ax]==0||t[s.by][s.bx]==0)return s.cost;
    
    for(int i=-4;i<=4;i++){
      for(int j=-4;j<=4;j++){
	state w=s;
	int ny,nx;
	if(s.f)ny=w.ay+i,nx=w.ax+j;
	else   ny=w.by+i,nx=w.bx+j;
	if(ny<0||nx<0)continue;
	if(ny>=H||nx>=W)continue;
	if(s.f)w.ay=ny,w.ax=nx;
	else   w.by=ny,w.bx=nx;
	w.f=1-s.f;
	w.cost=s.cost+t[ny][nx];
	if(w.bx>=w.ax)continue;
	if(dist(w.ay,w.ax,w.by,w.bx)>3)continue;
	if(w.cost>d[w.ay][w.ax][w.by][w.bx][w.f])continue;
	d[w.ay][w.ax][w.by][w.bx][w.f]=w.cost;
	Q.push(w);
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>W>>H;
    if(W==0&&H==0)break;
    init();
    char ch;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>ch;
	t[i][j]=INF;
        if(ch=='S')A.push_back(P(j,i));
	else if(ch=='T')t[i][j]=0;
	else if('0'<=ch&&ch<='9')t[i][j]=ch-'0';
      }
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 37344
import sys
from itertools import product
input = lambda: sys.stdin.readline().rstrip()

h, w, k = map(int, input().split())
c = [[i for i in list(str(input()))] for i in range(h)]

def check(sh, sw):
   cnt = 0
   for i in range(h):
      if sh[i]:
         continue
      for j in range(w):
         if sw[j]:
            continue
         if c[i][j] == "#":
            cnt += 1
   return cnt

ans = 0
for p1 in product(range(2), repeat=w):
   for p2 in product(range(2), repeat=h):
      if check(p2, p1) == k:
         ans += 1
print(ans)

Measured memory_bytes: 68652
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)

Measured memory_bytes: 78220
import collections
n=int(input())
a=list(map(int,input().split()))
b = collections.Counter(a)
total = 0

for i in b.values():
  total += i*(i-1)//2
  
for i in a:
  c = b[i]
  print(total-(c*(c-1)//2)+((c-1)*(c-2)//2))
  
  
 


Measured memory_bytes: 26772
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> Train = new ArrayList<>();
        
        while(sc.hasNext()){
            int N = sc.nextInt();
            if(N == 0){
                System.out.println(Train.get(Train.size()-1));
                Train.remove(Train.size()-1);
            }else{
                Train.add(N);
            }
        }
    }
}


Measured memory_bytes: 26308
#include <cstdio>
#include <set>
#include <queue>
using namespace std;

typedef long long LL;

inline LL flag(int y, int x){
	return 1LL << ((y - 1) * 7 + (x - 1));
}

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

int h, w;
int c[9][9];
int lasty, lastx;
set<LL> fail;

bool tmp[9][9];

bool check_connect(LL S){
	for(int i = 0; i < 9; ++i)
	for(int j = 0; j < 9; ++j){
		tmp[i][j] = false;
	}
	
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		if(S & flag(i, j)){
			tmp[i][j] = true;
		}
	}

	bool cnt = false;
	queue<int> q;
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		if(tmp[i][j]){
			if(cnt) return false;
			cnt = true;
			tmp[i][j] = false;
			q.push(i << 4 | j);

			while(!q.empty()){
				for(int k = 0; k < 4; ++k){
					int y = (q.front() >> 4) + dy[k];
					int x = (q.front() & 15) + dx[k];
					if(tmp[y][x]){
						tmp[y][x] = false;
						q.push(y << 4 | x);
					}
				}
				q.pop();
			}
		}
	}
	return true;
}

bool dfs(int y, int x, LL S){
	LL T = S << 8 | (y << 4) | x;
	if(!fail.insert(T).second) return false;

	if(!check_connect(S)) return false;

	for(int i = 0; i < 4; ++i){
		int ny = y + dy[i], nx = x + dx[i];
		LL f = flag(ny, nx);
		if(!c[ny][nx] && (S & f)){
			if(ny == lasty && nx == lastx){
				if(S == f) return true;
			}
			else if(dfs(ny, nx, S ^ f)){
				return true;
			}

			if(y == lasty && x == lastx){
				break;
			}
		}
	}

	return false;
}

bool solve(){
	fail.clear();

	LL S = 0;
	int firsty = -1, firstx = -1;
	int cnt0 = 0;
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		if(!c[i][j]){
			++cnt0;
			S |= flag(i, j);
			if(firsty == -1){
				firsty = i;
				firstx = j;
			}
		}
	}

	if(S == 0) return false;
	if(cnt0 % 2) return false;

	lasty = firsty;
	lastx = firstx;
	return dfs(firsty, firstx, S);

}

int main(){
	while(scanf("%d%d", &w, &h), w){
		for(int i = 0; i < 9; ++i)
		for(int j = 0; j < 9; ++j){
			c[i][j] = 1;
		}
		
		for(int i = 1; i <= h; ++i)
		for(int j = 1; j <= w; ++j){
			scanf("%d", &c[i][j]);
		}

		puts(solve() ? "Yes" : "No");
	}
}

Measured memory_bytes: 11776
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var count = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == t[i]) count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
S = gets.chomp
if S[-1] == "1"
  p -1; exit
end
n = S.size
T = S[0...-1]
if T.reverse != T || T[0] != "1"
  p -1; exit
end

k = 1
(1..(T.size+1)/2).reverse_each{ |i|
  if T[i-1] == "1"
    r = k
    (n - i - 1).times{
      puts "#{r} #{k += 1}"
    }
    puts "#{r} #{k += 1}"    
    n = i
  end
}


Measured memory_bytes: 3580
using System;
class Program
{
	static void Main(string[] args)
	{
		String[] s = Console.ReadLine().Split(' ');
      	int na = int.Parse(s[0]) * int.Parse(s[1]);
        int b = int.Parse(s[2]);
		Console.WriteLine((na>b)?b:na);
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<iterator>
using namespace std;

int main()
{
    int N;
    cin>>N;
    if(N>=30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

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

int main() {
	double bmi;
	int s;
	double w, h;
	while (scanf("%d,%lf,%lf", &s, &w, &h) + 1) {
		bmi = w / (h*h);
		if (bmi >= 25) {
			cout << s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3204
#ヘボくてすみません

$result = Array.new
debug = false

def min(a,b)
  if a < b then
    return a
  else
    return b
  end
end

N,M,R = gets.split("\s").map {|s|s.to_i}
r = gets.split("\s").map {|s|s.to_i}

# ワーシャルフロイド法
#   最短経路を求める時、その途中の点においても最短経路である
dist = Array.new(N) {Array.new(N,1000000000)}
M.times do
  a,b,c = gets.split("\s").map {|s|s.to_i}
  dist[a-1][b-1] = c
  dist[b-1][a-1] = c
end

N.times do |k|  ## 中継点
  N.times do |i|
    N.times do |j|
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
    end
  end
end

N.times do |i|
  N.times do |j|
    print "#{dist[i][j]} " if debug
  end
  puts "" if debug
end

result = 100000000
r.permutation do |x|
p x if debug
  s = 0
  (R-1).times do |i|
    s += dist[x[i]-1][x[i+1]-1]
  end
  result = min(result, s)
end
p result

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

using namespace std;

int main(){

    string S;
    cin >> S;

    int N = S.size();

    char c;
    string cand1(S);
    c = '0';
    for(int i = 0; i < N; i++){
	cand1.at(i) = c;
	c = c == '0' ? '1' : '0';
    }
    string cand2(S);
    c = '1';
    for(int i = 0; i < N; i++){
	cand2.at(i) = c;
	c = c == '0' ? '1' : '0';
    }

    int diff1 = 0, diff2 = 0;
    for(int i = 0; i < N; i++){
	if(cand1.at(i) != S.at(i)) diff1++;
	if(cand2.at(i) != S.at(i)) diff2++;
    }

    cout << min(diff1, diff2) << endl;
    
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
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; }

using Lint=long long;

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

    int N; cin>>N;
    for(int i=1;i<=N;i++){
        int t=i*1.08;
        if(t==N){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  work_acm
//
//  Created by 李锦涛 on 2020/6/15.
//  Copyright © 2020 Big_N_R. All rights reserved.
//


#include<iostream>
#include<vector>
using namespace std;
#define sc(x) scanf("%d",&x)
const int maxn=2e5+5;
int vis[maxn*10],n,a[maxn];
vector<int> re;
vector<int> get_factor(int x){
    int i=1;
    re.clear();
    while(i*i<=x){
        if(x%i==0){
            re.push_back(i);
            if(i*i!=x){
                re.push_back(x/i);
            }
        }
        i++;
    }
    return re;
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        vis[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        vis[a[i]]--;
        auto it=get_factor(a[i]);
        bool exist=1;
        for(auto j:it)
            if(vis[j]) {
                exist = 0;
                break;
            }
        ans+=exist;
        vis[a[i]]++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 7916
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
using namespace std;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(n) scanf("%s",&n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mes(a,b) memset(a,b,sizeof a)
#define mem(a,b,n) memset(a,b,n*sizeof(int))
#define uint unsigned int

const  int N = 1e5 + 1000;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;

int n;
map<string, int> mp;

int main()
{
	string s;
	sc(n);
	ll ans = 0;
	fo(i, 1, n)
	{
		cin >> s;
		sort(s.begin(), s.end());
		if (mp[s])
			ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  string a; cin >> a;
  rep(s,1<<3){ //000 ~ 111
    string siki = "";
    siki += a[0];
    int ans = a[0]-'0';
    rep(i,3){
      if(s>>i&1) {
        ans += a[i+1]-'0';
        siki += "+";
        siki += a[i+1];
      }else{
        ans -= a[i+1]-'0';
        siki += "-";
        siki += a[i+1];
      }
    }
    siki += "=7";
    if(ans == 7){
      cout << siki << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];


    vector<int> T(D);
    REP(i, 0, D) {
        int max_idx = 0;
        REP(j, 0, 26) {
            if (S[i][max_idx] < S[i][j]) max_idx = j;
        }
        T[i] = max_idx;
    }

    vector<int> last(26, 0);
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i]] += S[i][T[i]];
        last[T[i]] = i + 1;
        REP(j, 0, 26) {
            ret[j] -= C[j] * (i + 1 - last[j]);
        }
    }

	auto start = std::chrono::system_clock::now();
    const ll limit = 1950*1000;

    ll best = accumulate(ALL(ret), 0LL);
    mt19937_64 mt(random_device{}());
    uniform_int_distribution<int> day(0, D - 1);
    uniform_int_distribution<int> con(0, 25);
    while (1) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
        if(elapsed > limit) break;

        int d = day(mt);
        int next = con(mt);
        int prev = T[d];
        T[d] = next;
        last[prev] = 0;
        last[next] = 0;
        ll oldp = ret[prev];
        ll oldn = ret[next];
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev || T[i] == next) {
                ret[T[i]] += S[i][T[i]];
                last[T[i]] = i + 1;
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev]);
            ret[next] -= C[next] * (i + 1 - last[next]);
        }
        if (best >= accumulate(ALL(ret), 0LL)) {
            T[d] = prev;
        } else {
            best = accumulate(ALL(ret), 0LL);
            ret[prev] = oldp;
            ret[next] = oldn;
        }
        // cout << best << endl;
    }
    
    for (auto t : T) cout << t + 1 << endl;
    return 0;
}

Measured memory_bytes: 3724
# sh_yamaさんの回答
n, m = map(int, input().split())  # n,mはそれぞれ問題数、解いた数
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
    p, s = input().split()  # input().split()を使えばよい
    p = int(p) - 1  # 何問目か？（-1は番目を合わせる為）
    if s == 'WA':
        if ac[p] == 0:  # WAでまだ未ACという事を示す
            pen[p] += 1  # このときペナルティを加える
    else:  # 問題pがACの時
        ac[p] = 1  # p問目を既ACにする

for p in range(n):
    if ac[p] == 0:
        pen[p] = 0  # 未ACの問題はペナルティも０にする

print(sum(ac), sum(pen))

Measured memory_bytes: 4732
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x==1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
//vector <bool> prime(boolsize,1);
//void seive()
//{
//    ll n=boolsize;
//    prime[0]=prime[1]=0;
//    for(ll i=2;i<=sqrt(boolsize);i++)
//    {
//        if(prime[i]==1)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//            {
//                prime[j]=0;
//            }
//        }
//    }
//}

void fun()
{

}
/// check for test case before submitting
void vfun()
{
    ll n,mp,x,y;
    cin>>n>>mp;
    map <ll,ll> m;
    fo(i,mp)
    {
        cin>>x>>y;
        m[x]++;
        m[y]++;
    }
    fo1(i,n)
        {
            auto it=m.find(i);
            if(it==m.end())
                cout<<"0\n";
            else
                cout<<it->second<<endl;
        }
    cout<<endl;

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        //fun();
        vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not



Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int vis[300008];
ll dist[300008];
vector<int> e[300008];
int n;
void add(int u, int v)
{
  e[u].pb(v+n);
  e[u+n].pb(v+2*n);
  e[u+2*n].pb(v);
}

int main()
{
  int m,i,j;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    int u,v;
    cin>>u>>v;
    add(u,v);
  }
  int s,t;
  cin>>s>>t;
  vis[s]=1;
  queue<int> q;
  q.push(s);
  int f=0;
  while(!q.empty())
  {
    int u = q.front();
    q.pop();
    if(u==t) break;
    for(auto v: e[u])
    {
      if(!vis[v])
      {
		q.push(v);
		vis[v]=1;
        dist[v]=dist[u]+1;
      }
    }

  }
  if(dist[t]!=0 && dist[t]%3==0) {
  cout<<dist[t]/3;
  }
  else cout<<-1;
  return 0;
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
using ll = long long;
int main(){
    int a,b;
    cin>>a>>b;
    int mx=max(a,b);
    if ((mx-1<a & mx-1<b) ? mx*=2 : mx=mx*2-1);
    cout<<mx<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int ans = 1000000007;
    REP(i,-100,100+1) {
        int cnt = 0;
        REP(j,0,n) {
            int diff = i - a[j];
            cnt += diff * diff;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

int p[100][100], t[100][100];

signed main(){ INIT;
    VAR(string, s);
    int ans = INF;
    FOR(a, 'a', 'z'+1){
        int M = 0, t = 0;
        AREP(b, s){
            if(b != a) t++;
            else M = max(M, t), t = 0;
        }
        M = max(M, t);
        ans = min(ans, M);
    }
    OUTL(ans);
RET;}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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)*) => {
        #[allow(unused_mut)]
        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, 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")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [usize; n],
    }
    let p = p
        .iter()
        .map(|pi| ((1 + pi) as f64) / 2_f64)
        .collect::<Vec<f64>>();
    let mut ans = p.iter().take(k).sum::<f64>();
    let mut before = ans;
    for i in 0..(n - k) {
        let t = before - p[i] + p[i + k];
        ans = ans.max(t);
        before = t;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import java.util.Scanner


object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b = sc.nextInt()
    val result =
      if(0<= a && a <= 5) 0
      else if(6<= a && a<= 12) b/2
      else b
    println(result)
  }
}

Measured memory_bytes: 25928
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string s,t;
    cin>>s;
    
    t=s;
    reverse(t.begin(),t.end());
    
    if(s.compare(t)==0)
    {
        string u=s.substr(0,(s.length()-1)/2);
        string uu=u;
        reverse(uu.begin(),uu.end());
        if(u.compare(uu)==0)
        {
            string q=s.substr((s.length()+1)/2,(s.length()-1)/2);
            string qq=q;
            reverse(qq.begin(),qq.end());  
            if(q.compare(qq)==0)
            {
                cout<<"Yes";
                return 0;
            }
            else
            {
                cout<<"No";
                return 0;
            }
        }
        else
        {
            cout<<"No";
            return 0;
        }
    }
    else
    {
        cout<<"No";
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> v(h);
  rep(i,h) cin>>v[i];

  const int INF = h*w;

  vector<vector<int>> d(h,vector<int>(w,INF));

  using P = pair<int,int>;
  queue<P> q;
  rep(i,h) rep(j,w) if(v[i][j] == '#') {
    d[i][j] = 0;
    q.push({i,j});
  }

  int ans = 0;
  while(!q.empty()){
    auto p = q.front(); q.pop();
    int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
    rep(k,4){
      int nx = p.first + dx[k];
      int ny = p.second + dy[k];
      if(nx>=0 && ny>=0 && nx < h && ny < w && d[nx][ny] == INF) {
        d[nx][ny] = d[p.first][p.second] + 1;
        q.push({nx,ny});
        ans = d[nx][ny];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13456
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		a: isize,
		b: isize,
	}

	println!("{}", max(a+b, max(a-b, a*b)));
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz],dp[sz],k;

int clac(int i){
    if(i==n) return 0;
    if(dp[i]!=-1)return dp[i];
/*    int left=abs(arr[i]-arr[i+1])+clac(i+1);
    int right=inf;
    if(i+2<=n){
        right=abs(arr[i]-arr[i+2])+clac(i+2);
    }
    */
    int ret1=inf;
    for(int j=1;j<=k && i+j<=n;j++){
        ret1=min(ret1,abs(arr[i]-arr[i+j])+clac(i+j));
    }
    return dp[i]=ret1;
}

void solve(){
    cin>>n>>k;
    reset(dp,-1);
    lp(i,1,n+1)cin>>arr[i];
    cout<<clac(1)<<"\n";
}

int main(){
    //FasterIO;
    #ifndef ONLINE_JUDGE
       //freopen("1.txt","r",stdin);
   #endif
   // int t;
    //cin>>t;
    //while(t--)
        solve();
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

bool sameparity(int a, int C)
{
	if((a % 2 == 0 && C % 2 == 0) ||
	(a % 2 == 1 && C % 2 == 1))
		return true;
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int a, b, c;
	cin >> a >> b >> c;

	int C = c % b;
	if(sameparity(a, C))
		cout << "YES" << endl, exit(0);
	
	for(int i = a + a; i < 10000; i += a)
		if(i % b == C)
			cout << "YES" << endl, exit(0);
	
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >>c;
    cout << (char)((a[0]-'a')+'A') <<(char)((b[0]-'a')+'A')<<(char)((c[0]-'a')+'A')<< endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

int N, C[500], S[500], F[500];

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++)  cin >> C[i] >> S[i] >> F[i];

    for(int i=0;i<N-1;i++){
        ll res = S[i] + C[i];
        for(int j=i+1;j<N-1;j++){
            if(res <= S[j]){
                res = S[j] + C[j];
                continue;
            }
            int n = (res - S[j]) / F[j];
            if(S[j] + F[j] * n < res)   n++;
            res = S[j] + F[j] * n + C[j];
        }
        cout << res << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
	ll l,r;
	cin>>l>>r;
	rep(i,l,r+1){
		if(i%2019==0){
			cout << 0 << endl;
			return 0;
		}
	}
	ll mn = 4000000000000000010LL;
	rep(i,l,r+1){
		rep(j,i+1,r+1){
			ll a = i*j;
			mn = min(mn,a%2019);
		}
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

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

    OUT((a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000));
    return 0;
}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

int main(){
    ll n;
    while(cin >> n, n){
    if(n<=0) return 0;
	ll dp[n+1];
	dp[0]=1;
	dp[1]=1;
	dp[2]=2;
	if(n>=3)rep(i,n-2) dp[i+3]=dp[i+2]+dp[i+1]+dp[i];
	
	ll N=dp[n];
	N+=10;
	N/=10;
	N+=364;
	N/=365;
	cout<<N<<endl;
    }
}


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

int n, a[15],dp[2][15];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    if(a[0]%2==0){
        dp[0][0] = 1;
        dp[1][0] = 2;
    }
    else{
        dp[0][0] = 2;
        dp[1][0] = 1;
    }
    for(int i = 1; i < n; i++){
        if(a[i]%2==0){
            dp[0][i] = dp[0][i-1] + dp[1][i-1] + 2*dp[0][i-1];
            dp[1][i] = 2 * dp[1][i-1];
        }
        else{
            dp[0][i] = 2*(dp[0][i-1] + dp[1][i-1]) + dp[0][i-1];
            dp[1][i] = dp[1][i-1];
        }
    }
    cout<<dp[0][n-1];

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int D, T, S;
    cin >> D >> T >> S;
    cout << ((D + S - 1) / S <= T ? "Yes" : "No") << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);

  unordered_map<ll, ll> mp;
  for(ll i=2; i*i<=N; ++i){
    while(N%i==0){
      mp[i]++;
      N/=i;
    }
  }
  if(N!=1) mp[N]++;

  ll ans = 0;
  for(auto itr : mp){
    ll start = 1;
    ll se = itr.second;
    while(se>=start){
      ans++;
      se-=start;
      start++;
    }
  }

  OUT(ans);


  return 0;
}


Measured memory_bytes: 3656