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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0, ans = 0;
    for(int i=0;i<n;++i){
        x += (s[i] == 'I' ? 1 : -1);
        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);
template <typename T> struct LazySegmentTree {
  
  int n;
  vector<T> node, lazy;

  LazySegmentTree (int sz, T init = 0) {
    n = 1; while (n < sz) n <<= 1;
    node.assign(2*n, init);
    lazy.assign(2*n,0); 
  }

  void eval (int k) {
    if (lazy[k] == 0) return ;
    node[k] += lazy[k];
    if (k < n) {
      lazy[2*k+1] += lazy[k];
      lazy[2*k+2] += lazy[k];
    }
    lazy[k] = 0;
  }

  void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
    eval(k);
    if (r < 0) r = n;
    if (b <= l || r <= a) return ;
    if (a <= l && r <= b) {
      lazy[k] = x;
      eval(k);
    } else {
      update(a, b, x, 2*k+1, l, (r+l)/2);
      update(a, b, x, 2*k+2, (r+l)/2, r);
      node[k] = node[2*k+1] + node[2*k+2];
    }
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    eval(k);
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2*k+1, l, (l+r)/2);
    T vr = query(a, b, 2*k+2, (l+r)/2, r);
    return vl + vr;
  }

};

int main(){ 
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  LazySegmentTree<ll> seg(n);
  rep(i,n) seg.update(i,i+1,p[i].second);
  ll res = 0;
  for (int i = 0; i < n; i++) {
    ll v = seg.query(i,i+1);
    if (v <= 0) continue;
    ll cnt = (v + a - 1 ) / a;
    res += cnt;
    auto itr = lower_bound(p.begin(), p.end(), make_pair(p[i].first+d*2, INF)) - p.begin();
    seg.update(i,itr,-cnt*a);
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 11520
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(int argc,char** argv)
{
	char c[2][3];
	for(int i = 0; i < 2; i++){
			scanf("%s", c[i]);
	}
 
	if(c[0][0] == c[1][2]){
		if(c[0][1] == c[1][1]){
			if(c[0][2] == c[1][0]){
				printf("YES\n");
			}
			else{printf("NO\n");}
		}
		else{printf("NO\n");}
	}
	else{printf("NO\n");}
 
	return(0);
 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	string s;
	cin >> n >> s;
	map<pair<int,string>,int> cnt;
	for(int i = 0;i < (1 << n);i++){
		string a,b;
		for(int j = 0;j < n;j++){
			if((i >> j) & 1) a += s[j];
			else b += s[j];
		}
		reverse(all(b));
		cnt[mp(__builtin_popcountll(i),a + b)]++;
	}
	int ans = 0;
	for(int i = 0;i < (1 << n);i++){
		string a,b;
		for(int j = 0;j < n;j++){
			if((i >> j) & 1) b += s[j + n];
			else a += s[j + n];
		}
		reverse(all(a));
		ans += cnt[mp(n - __builtin_popcountll(i),a + b)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 68224
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    cout << ab * bc / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(rALL(l));

    int tmp = 0;
    Rep(i, 1, n)
    {
        tmp += l[i];
    }
    if (tmp > l[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.*;

/**
 *
 * @author Admin
 */
class Main {
    
    
    public static void main(String args[])
    {
    Scanner s=new Scanner(System.in);
    
    int a=s.nextInt();
    
   TreeSet<String> set=new TreeSet<>();
    
    while(a-->0)
    {
    String str=s.next();
    
    set.add(str);
    }
    System.out.println(set.size());
    
    
    }
    
    
}


Measured memory_bytes: 74328
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B;

  cin >> A >> B;

  if (A == B) {
    cout << A + B << endl;
  } else {
    int t = max(A, B);
    cout << t + t - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std ;
int main(){
string a[100001] ;
int n , l ; cin >> n >> l;
for(int i = 0 ; i < n ; i++){
cin >> a[i] ;
}
sort(a,a+n);
for(int i =  0; i < n ; i++) cout <<a[i];

}

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

int N; long double p[10009], dp[3009][3009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> p[i];

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N; j++) {
			dp[i + 1][j + 1] += dp[i][j] * p[i + 1];
			dp[i + 1][j] += dp[i][j] * (1.0L - p[i + 1]);
		}
	}
	long double E = 0;
	for (int i = (N / 2) + 1; i <= N; i++) E += dp[N][i];
	printf("%.12Lf\n", E);
	return 0;
}

Measured memory_bytes: 141568
import sys
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

sum_S = sum(S)
if sum_S % 10 != 0:
    print(sum_S)
    sys.exit()

S.sort()

for s in S:
    if s % 10 != 0:
        print(sum_S - s)
        sys.exit()
else:
    print(0)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    string a,b;
    cin >> a >> b;
    for(int i=0;i<a.size();i++){
        cout << a[i];
        if(i<b.size())cout << b[i];
    }
    cout << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn=1e7+10;
int n,a[maxn],p[maxn],b[maxn];
vector<int> v;
void init(){
	for(int i=2;i<10006;i++){
		if(p[i]) continue;
		v.push_back(i);
		for(int j=i*i;j<10006;j+=i) p[j]=1;
	}
}
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}

int main()
{
	init();
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int x=a[1];
	for(int i=2;i<=n;i++) x=gcd(a[i],x);
	if(x!=1) cout<<"not coprime";
	else{
		bool flag=true;
		for(int i=1;i<=n;i++){
			int x=a[i],j=0;if(x==1) continue;
			while(x>1){
				if(x%v[j]==0&&b[v[j]]){
					flag=false;break;
				}
				while(x%v[j]==0) x/=v[j],b[v[j]]=1;
				j++;
				if(j>=v.size()){
					if(b[x]) flag=false;
					b[x]=1;break;
				}
			}
			if(!flag) break;
		}
		if(flag) cout<<"pairwise coprime";
		else cout<<"setwise coprime";
	}
	return 0;	
} 

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	VS s(2*n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		s[i] += s[i];
		s[n+i] = s[i];
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int tmp = 1;
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				if (j == k) {continue;}
				if (s[i+j][k] != s[i+k][j]) {
					tmp = 0;
				}
			}
		}
		ans += tmp*n;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
X, N = map(int, input().split())
if not N ==0:
  A = [int(x) for x in input().split()]
  index = 0
  value = abs(A[0] - X)
  up_list = [0]*(N+1)
  down_list = [0]*(N+1)

  for i in range(N):
    if abs(A[i] - X ) < N+1:
      if A[i] - X >= 0:
        up_list[A[i]-X] = 1
      if A[i] - X <= 0:
        down_list[abs(A[i]- X)] = 1

  j = 0
  while True:
    if down_list[j] == 0:
      print(X-j)
      break
    if up_list[j] ==0:
      print(X+j)
      break
    if j>N+1:
      print('fail')
      break
    j+=1

else:
  print(X)


Measured memory_bytes: 9168
#include <stdio.h>
#include <iostream>
using namespace std;

int main () {
	int A,B ;
	cin >> A >> B;
	if  (A==B){
		cout << "Draw";
	}else if (A==1){
		cout << "Alice";
	}else if (B==1){
		cout << "Bob";
	}else if (A<B){
		cout << "Bob";
	}else if (A>B){
		cout << "Alice";
	}
}

Measured memory_bytes: 256
import sys
from heapq import*
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0
 H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
def s():
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  E=[[]for _ in[0]*-~n]
  for _ in[0]*k:
   f=r()
   if'0'==f[0]:print(g(n,E,*map(int,f[2:].split())))
   else:
    c,d,e=map(int,f[2:].split())
    E[c]+=[(e,d)];E[d]+=[(e,c)]
if'__main__'==__name__:s()


Measured memory_bytes: 6308
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
typedef struct{
    int d,p;
}data;
int cmp_d(const void *a,const void *b){
    return ((data*)b)->p-((data*)a)->p;
}
int main(void){
    int n,m,d,p,i,ans;
    data a[10000];
    while(1){
        n=in();
        m=in();
        if(!n)break;
        rep(i,n){
            a[i].d=in();
            a[i].p=in();
        }
        qsort(a,n,sizeof(data),cmp_d);
        ans=0;
        rep(i,n){
            if(m>=a[i].d)m-=a[i].d;
            else{
                if(m){
                    a[i].d-=m;
                    m=0;
                }
                ans+=a[i].d*a[i].p;
            }
        }
        print(ans);
    }
    return 0;
}



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

int main() {
	int A, B; cin >> A >> B;

	long long ans = 0;
	for (int i = A; i <= B; i++) {
		string tmp; tmp = to_string(i);				
		bool ok = true;
		for (int j = 0; j < tmp.size(); j++) {
			if (tmp[j] != tmp[tmp.size() -1 - j]) {
				ok = false;
				break;
			}
		}
		if (ok)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

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

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

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

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

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

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

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

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

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

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

signed solve()
{
	auto c1 = IN<string>();
	auto c2 = IN<string>();
	if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0])
		print("YES");
	else
		print("NO");
	return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

//境界値に注意！！！

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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[505], b[505], c[505];
void solve(){
	cin >> n;
	for(int i = 1; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		for(int j = i; j < n; j++){
			cnt = max(b[j], (cnt+c[j]-1)/c[j]*c[j]);
			cnt += a[j];
		}
		cout << cnt << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
from math import ceil
N = int(input())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7

# 間の距離を計算
distances = [0] + [X[i + 1] - X[i] for i in range(N - 1)]

# (N - 1)!を計算
factorial_n_1 = 1
for i in range(1, N):
    factorial_n_1 *= i
    factorial_n_1 %= MOD


expected_cnt = [0] * N
for i in range(1, N):
    expected_cnt[i] = expected_cnt[i - 1] + (factorial_n_1 * pow(i, MOD - 2, MOD)) % MOD

moves = [(d * e) % MOD for d, e in zip(distances, expected_cnt)]
print(sum(moves) % MOD)


Measured memory_bytes: 19756
n, x = map(int, input().split())
m = list(int(input()) for _ in range(n))
c = 0
for i in range(n):
    if x < m[i]:
        break
    else:
        x -= m[i]
        c += 1
m.sort()
while x >= m[0]:
    x -= m[0]
    c += 1

print(c)

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,Q;
string name[100000];
int tim[100000];

int que[500010];
int head,tail;
void push(int p){
    que[tail++]=p;
}
void pop(){
    assert(head<tail);
    head++;
}
int front(){
    return que[head];
}
bool empty(){
    return head==tail;
}

signed main(){
    cin>>N>>Q;
    rep(i,N)cin>>name[i]>>tim[i];

    rep(i,N)push(i);
    int sum=0;
    while(!empty()){
        int v=front();pop();
        sum+=min(tim[v],Q);
        tim[v]-=Q;
        if(tim[v]<=0){
            cout<<name[v]<<" "<<sum<<endl;
        }
        else push(v);
    }

    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;

int main(){
  cin >> n;
  cout << "AB" << (char)('C'+(n/1000)) << endl;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

ll pow_mod(ll n, ll m, ll mod){
    ll a = 1;
    while(m>0){
        if(m&1) a = a*n % mod;
        n = n*n % mod;
        m >>= 1;
    }
    return a;
}

int main(){
    string s;
    cin >> s;
    ll n = s.length();
    vll t;
    ll l = 0;
    while(l<n){
        ll count = 1;
        char c = s[l];
        REP(i, l+1, n){
            if(s[i]==c) ++count;
            else break;
        }
        if(count>=4){
            count = (count/2) * 2;
            if(c=='L'){
                t.push_back(-count/2);
                t.push_back(-count/2);
            }
            else{
                t.push_back(count/2);
                t.push_back(count/2);
            }
        }
        else{
            rep(i, count){
                t.push_back(c=='L'? -1 : 1);
            }
        }
        l += count;
    }
    vll t1(t.size());
    vll t2(t.size());
    rep(i, t.size()){
        t1[i] = abs(t[i]);
        t2[i] = abs(t[i]);
    }
    rep(i, 4){
        rep(j, t.size()){
            ll count = 0;
            if(j>0 && t[j-1]>0){
                count += t1[j-1];
            }
            if(j+1<t.size() && t[j+1]<0){
                count += t1[j+1];
            }
            t2[j] = count;
        }
        rep(j, t.size()){
            t1[j] = t2[j];
        }
    }
    vll g;
    rep(i, t.size()){
        if(i>0 && t[i-1]*t[i]<0){
            g.push_back(t2[i]);
        }
        else if(i+1<t.size() && t[i]*t[i+1]<0){
            g.push_back(t2[i]);
        }
    }

    ll last = 0;
    rep(i, n){
        if(i>0 && s[i]!=s[i-1]){
            cout << g[last] << " ";
            ++last;
        }
        else if(i+1<n && s[i]!=s[i+1]){
            cout << g[last] << " ";
            ++last;
        }
        else{
            cout << 0 << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=998244353;
typedef vector<int> vec;
typedef vector<vec> mat;
const double EPS=1E-8;//小さい数
int mat_rank(mat A) {
    int N = A.size(), M = A[0].size();
    int res = 0;
    for(int i=0; i<M; i++) {
        // 絶対値が最も大きいものを探す
        double max_elem = 0; int piv = -1;
        for(int j=res; j<N; j++) {
            if(abs(A[j][i]) > max_elem) {
                max_elem = abs(A[j][i]);
                piv = j;
            }
        }
        if(piv < 0) continue;
        swap(A[res], A[piv]);
        /*for(int k=0; k<M; k++) {
            A[res][k] = (1.0 * A[res][k] / A[res][i]);
        }*/
        for(int j=0; j<N; j++) {
            if(j == res) continue;
            int mul = A[j][i];
            for(int k=0; k<M; k++) {
                A[j][k] = ((A[j][k] - mul * A[res][k])%2+2)%2;
            }
        }
        res++;
    }
    return res;
}
ll mod_pow(ll x, ll n, ll mod){
    if (n==0) return 1;
    ll res=mod_pow(x*x%mod, n/2, mod);
    if (n%2==1) res=res*x%mod;
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    mat a(N,vec(M,0));
    rep(i,0,N){
        rep(j,0,M){
            cin>>a[i][j];
        }
    }
    cout <<(mod_pow(2LL, N+M-1, MOD)-mod_pow(2LL, N+M-1-mat_rank(a), MOD)+MOD)%MOD<<"\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

map <string,int> MAP;
typedef struct Node{
	int to,dist;
}NODE;
NODE nd;
vector <Node> v1[6005],v2[305];
vector <int> gas;
int dis[6005],in[6005];

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int N,n,M,m,i,j,cap,c,d;
	while(cin >> N >> M >> cap,N){
		cap *= 10;
		for(n=0;n<2*N+2;n++)
			v1[n].clear();
		for(m=0;m<305;m++)
			v2[m].clear();
		MAP.clear();
		gas.clear();
		string head,tail;
		cin >> head >> tail;
		c = 0;
		for(n=0;n<N;n++){
			string c1,c2;
			cin >> c1 >> c2 >> d;
			if(MAP.find(c1)==MAP.end())	MAP[c1] = c++;
			if(MAP.find(c2)==MAP.end())	MAP[c2] = c++;
			nd.to = MAP[c2];
			nd.dist = d;
			v1[MAP[c1]].push_back(nd);
			nd.to = MAP[c1];
			v1[MAP[c2]].push_back(nd);
		}
		for(m=0;m<M;m++){
			string c1;
			cin >> c1;
			gas.push_back(MAP[c1]);
		}
		if(MAP.find(head)==MAP.end()){
			printf("-1\n");
			continue;
		}
		if(MAP.find(tail)==MAP.end()){
			printf("-1\n");
			continue;
		}
		int pos1=gas.size(),pos2=gas.size()+1;
		gas.push_back(MAP[head]);
		gas.push_back(MAP[tail]);
		for(i=0;i<gas.size();i++){
			for(j=0;j<6005;j++)
				dis[j] = 1e9;
			dis[gas[i]] = 0;
			memset(in,0,sizeof(in));
			int st;
			queue <int> q;
			q.push(gas[i]);
			while(!q.empty()){
				st = q.front();	q.pop();
				in[st] = 0;
				for(j=0;j<v1[st].size();j++){
					if(dis[st]+v1[st][j].dist < dis[v1[st][j].to]){
						dis[v1[st][j].to] = dis[st]+v1[st][j].dist;
						if(in[v1[st][j].to] == 0){
							q.push(v1[st][j].to);
							in[v1[st][j].to] = 1;
						}
					}
				}
			}
			for(j=0;j<gas.size();j++){
				if(gas[j]==gas[i])
					continue;
				if(dis[gas[j]]<=cap){
					nd.to = j;
					nd.dist = dis[gas[j]];
					v2[i].push_back(nd);
				}
			}
		}
		for(j=0;j<6005;j++)
			dis[j] = 1e9;
		memset(in,0,sizeof(in));
		int st=pos1,ans=1e9;
		dis[st] = 0;
		queue <int> q;
		q.push(st);
		while(!q.empty()){
			st = q.front();	q.pop();
			in[st] = 0;
			for(i=0;i<v2[st].size();i++){
				if(dis[st]+v2[st][i].dist < dis[v2[st][i].to]){
					dis[v2[st][i].to] = dis[st]+v2[st][i].dist;
					if(in[v2[st][i].to]==0){
						in[v2[st][i].to] = 1;
						q.push(v2[st][i].to);
					}
				}
			}
		}
		if(dis[pos2]!=1e9)
			printf("%d\n",dis[pos2]);
		else
			printf("-1\n");
	}
	
	return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>
    int main(void){
      int a,b,c,d,left,right;
      scanf("%d %d %d %d",&a,&b,&c,&d);
      left=a+b;
      right=c+d;
      if(left>right){
        printf("Left\n");
      }else if(left==right){
        printf("Balanced\n");
      }else{
        printf("Right\n");
      }
      return 0;
    }

Measured memory_bytes: 128
#include <stdio.h>
struct s{
  int num;
  char moji;
  int key;
};
struct s A[100001];

int Partition(int p,int r){
  int i,j;
  struct s x,tmp;
  x.num=A[r].num;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x.num){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}
 
void Quicksort(int p,int r){
  int q;
  if(p<r){
    q=Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}

main(){
  char c1,c2,c3;
  int n,i,a,b=0;
  scanf("%d%c",&n,&c1);
  for(i=0;i<n;i++){
    scanf("%c%c%d%c",&A[i].moji,&c2,&A[i].num,&c3);
    A[i].key=i;
  }
  a = Partition(0,n-1);
  Quicksort(0,n-1);
  for(i=0;i<n;i++){
    if(A[i].key>A[i+1].key && A[i].num==A[i+1].num){
      b=1;
      break;
    }
  }
  if(b==0){
    printf("Stable\n");
  }
  if(b==1){
    printf("Not stable\n");
  }
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].moji,A[i].num);
  }
  return 0;
}
 

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

int main()
{
  int N;
  bool check=false;
  cin >> N;
  if (N/10 == 9)
  {
    check = true;
  }
  else if(N%10 == 9)
  {
    check = true;
  }
  if(check)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	 public static void main(String[] args){
	   Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  double sum = 0;
	  for(int i = 0; i < n; i++) {
		  double a = sc.nextDouble();
		  sum+=1/a;
	  }
	  sum = 1/sum;
	  System.out.println(sum);
	}
}

Measured memory_bytes: 24532
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 200005;
typedef long long ll;
const ll INF = 500000000000000;

int n,m,l[MAX_N],r[MAX_N],a[MAX_N];
ll tree[4*MAX_N],lazy[4*MAX_N];
int open[MAX_N],close[MAX_N];

void lazyupd(int i, int l, int r)
{
	if (lazy[i])
	{
		tree[i]+=lazy[i];
		if (l!=r)
			lazy[2*i]+=lazy[i],lazy[2*i+1]+=lazy[i];
		lazy[i]=0;
	}
}

void set(int i, int l, int r, int si, ll v)
{
	lazyupd(i,l,r);
	if (l==r)
	{
		tree[i]=v;
		return;
	}
	if ((l+r)/2>=si)
		set(2*i,l,(l+r)/2,si,v);
	else
		set(2*i+1,(l+r)/2+1,r,si,v);
	tree[i]=max(tree[2*i],tree[2*i+1]);
}

ll query(int i, int l, int r, int sr)
{
	lazyupd(i,l,r);
	if (l>sr)
		return -INF;
	if (r<=sr)
		return tree[i];
	return max(query(2*i,l,(l+r)/2,sr),query(2*i+1,(l+r)/2+1,r,sr));
}

void add(int i, int l, int r, int sr, int v)
{
	lazyupd(i,l,r);
	if (l>sr)
		return;
	if (r<=sr)
	{
		lazy[i]=v;
		lazyupd(i,l,r);
		return;
	}
	add(2*i,l,(l+r)/2,sr,v);
	add(2*i+1,(l+r)/2+1,r,sr,v);
	tree[i]=max(tree[2*i],tree[2*i+1]);
}
void add(int r, int v) { add(1,0,n,r,v); }

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=m; i++)
	{
		scanf("%d %d %d",l+i,r+i,a+i);
		open[i]=close[i]=i;
	}
	sort(open+1,open+1+m,[](const int &a, const int &b) {
		if (l[a]==l[b])
			return a<b;
		return l[a]<l[b];
	});
	sort(close+1,close+1+m,[](const int &a, const int &b) {
		if (r[a]==r[b])
			return a<b;
		return r[a]<r[b];
	});
	ll ans=0;
	int po=1,pc=1;
	for (int i=1; i<=n; i++)
	{
		for (;po<=m&&l[open[po]]==i; po++)
			add(l[open[po]]-1,a[open[po]]);
		for (;pc<=m&&r[close[pc]]==i-1; pc++)
			add(l[close[pc]]-1,-a[close[pc]]);
		ll h=query(1,0,n,i-1);
		ans=max(ans,h);
		set(1,0,n,i,h);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18

#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

ll N;
ll s[114514];
ll sz[114514] = {};
vector<int> G[114514];
vector<PII> e;
map<PII, ll> res;

void dfs(int v, int p){
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v);
		if(sz[G[v][i]]*2 != N)
			res[make_pair(min(v, G[v][i]), max(v, G[v][i]))] = abs(s[v]-s[G[v][i]])/abs(N-2*sz[G[v][i]]);
		sz[v] += sz[G[v][i]];
	}
	sz[v]+=1;
}

ll dfs2(int v, int p, ll sum){
	ll ret = 0;
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		ret += dfs2(G[v][i], v, res[make_pair(min(G[v][i], v), max(G[v][i], v))]+sum);
	}
	return ret+sum;
}

int main(void){
	cin >> N;
	REP(i, N-1){
		int u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
		e.push_back({min(u, v), max(u, v)});
	}
	REP(i, N){
		cin >> s[i];
	}
	dfs(0, -1);
	ll ret = dfs2(0, -1, 0);
	REP(i, e.size()){
		if(res[e[i]] != 0)
			cout << res[e[i]] << endl;
		else
			cout << (s[0]-ret)/(N/2) << endl;
	}
	cout << endl;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;
const long long maxx = 1000000000000000000LL;
int main(){
  prep();
  int x, y;
  cin >> x >> y;
  if (x == y && x == 1){
      cout << "1000000";
  }else{
      int arr[4] = {300000, 200000, 100000, 0};
      if (x > 3){
          x = 4;
      }
      if (y > 3){
          y = 4;
      }
      x--;
      y--;
      cout << arr[x]+arr[y];
  }
  return 0; 
}

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


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

    int n;
    cin >> n;
    vector <int> arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int cnt = 1;
    for(int i=1;i<n;i++){
        bool possible = true;
        for(int j=i-1;j>=0;j--){
            if(arr[j] > arr[i])
                possible = false;
        }
        if(possible)
            cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        l[a-1].append(b)

a = []
ans = 0

for i in range(m):
    for j in l[i]:
        heapq.heappush(a, (-1) * j)
    if a:
        ans += heapq.heappop(a) * (-1)
        
print(ans)


Measured memory_bytes: 72736
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = float("inf")
for i in range(1, n):
    a,b = i, n-i
    ans = min(ans, sum(map(int, str(a)))+sum(map(int, str(b))) )
print(ans)

Measured memory_bytes: 74396
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc166/tasks/abc166_e
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> v(n+1);
    for(int i = 1;i<=n;i++)
        cin >> v[i];

    map<ll,ll> m;
    for(int i = 1;i<=n;i++){
        if(m[i-v[i]] != 0)
            ans += m[i-v[i]];
        if(m[i+v[i]] != 0)
            m[i+v[i]] += 1;
        else{
            m[i+v[i]] = 1;
        }
    }

    cout << ans;
	return 0;
}

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

int main() {
  string s; cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    int n;
    cin>>n;
    rep (i,0,n)
    {
        cout<<"ACL";
    }
}


Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define N 20
int h , w;
char c[ N ][ N ];
int ord[ N ];
void check( int len ){
  unordered_set<LL> cand;
  for( int i = 0 ; i < w ; i ++ ){
    //string tmp = "";
    LL hs = 0 , rhs = 0;
    for( int j = 0 ; j < len ; j ++ )
      hs = hs * 26 + (c[ ord[ j ] ][ i ] - 'a');
    for( int j = len - 1 ; j >= 0 ; j -- )
      rhs = rhs * 26 + (c[ ord[ j ] ][ i ] - 'a');
      //tmp += t[ j ][ i ];
    //string rtmp = tmp;
    //reverse( rtmp.begin() , rtmp.end() );
    auto it = cand.find( rhs );
    if( it != cand.end() )
      cand.erase( it );
    else
      cand.insert( hs );
  }
  if( cand.size() < 2u ){
    puts( "YES" );
    exit(0);
  }
}
void gogo( int msk1 , int msk2 ){
  int tot1 = 0;
  for( int i = 0 ; i < h ; i ++ ){
    if( (msk1 >> i) & 1 )
      ord[ tot1 ++ ] = i;
  }
  int tot2 = tot1;
  for( int i = 0 ; i < h ; i ++ ){
    if( (msk2 >> i) & 1 )
      ord[ tot2 ++ ] = i;
  }
  do check( tot2 );
  while( next_permutation( ord + tot1 , ord + tot2 ) );
}
int main(){
  scanf( "%d%d" , &h , &w );
  for( int i = 0 ; i < h ; i ++ )
    scanf( "%s" , c[ i ] );
  if( h == 1 ){
    int cnt[ 26 ] = {};
    for( int i = 0 ; i < w ; i ++ )
      cnt[ c[ 0 ][ i ] - 'a' ] ++;
    int od = 0;
    for( int i = 0 ; i < 26 ; i ++ )
      od += cnt[ i ] & 1;
    puts( od > 1 ? "NO" : "YES" );
    return 0;
  }
  int need = (h + 1) / 2;
  for( int i = 0 ; i < (1 << h) ; i ++ ){
    if( __builtin_popcount( i ) != need ) continue;
    if( h & 1 ){
      for( int j = 0 ; j < h ; j ++ )
        if( (i >> j) & 1 )
          gogo( i ^ (1 << j) , ((1 << h) - 1) ^ i );
    }else
      gogo( i , ((1 << h) - 1) ^ i );
  }
  puts( "NO" );
}


Measured memory_bytes: 256
#include<stdio.h>

long sum(long x);

int main() {
	long N, f_N;
	scanf("%d", &N);
	f_N = sum(N);
	printf((N % f_N == 0) ? "Yes" : "No");
}

long sum(long x) {
	if (x < 10) {
		return x;
	} else {
		return x % 10 + sum(x / 10);
	}
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    
    int ans = C - (A - B);
    if (ans > 0) {
      System.out.println(C - (A - B));
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>

int amida[101][1001];

int main(void)
{
	int i,j;
	int n,m,a;
	int h,p,q;
	int x,y;
	
	while(1)
	{
		scanf("%d %d %d ",&n,&m,&a);
		if(n==0 && m==0 && a==0)break;
		
		for(i=0;i<=n;i++){
			for(j=0;j<=1000;j++){
				amida[i][j] = 0;
			}
		}
		
		for(i=0;i<m;i++)
		{
			scanf("%d %d %d",&h,&p,&q);
			for(j=p;j<q;j++)
			{
				amida[j][h] = 1;
			}
		}
		
		for(i=0;i<=1000;i++)
		{	
			if(amida[a][1000-i]){
				while(amida[a][1000-i])a++;
			}else if(amida[a-1][1000-i]){
				while(amida[a-1][1000-i])a--;
			}
		}

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

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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    int n,a,b,c,d,e;
    cin >> a >> b;
    if(b >= a){
        cout << "unsafe" << endl;
    }else{
        cout <<"safe" << endl;
    }


}


Measured memory_bytes: 3624
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

int64_t digit_sum(int64_t n){
  if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

int64_t to9(int64_t n) {
  int64_t k = 1;
  while (n >= 10) n /= 10, k *= 10;
  return n*k-1;
}

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

  int64_t n;
  cin >> n;
  cout << max(digit_sum(n), digit_sum(to9(n))) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a)
#define vi vector<int>
#define loop(i, n) for(int i=1;i<=n;i++)
#define loop0(i, n) for(int i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) scanf("%d", i)

long long int n, s, weight[101], value[101];
long long int dp[101][100001];

long long int solve(const long long int i, long long int s)
{
  if(i==n+1 || s==0)
    return 0;
  if(dp[i][s]!=-1)
    return dp[i][s];
  if(s<weight[i])
    return solve(i+1, s);
  return dp[i][s]=max(value[i]+solve(i+1, s-weight[i]), solve(i+1, s));
}
int main()
{
  memset(dp, -1, sizeof(dp));
  in(n);
  in(s);
  loop(i , n)
  {
    in(weight[i]);
    in(value[i]);
  }
  cout<<solve(1, s);
}



Measured memory_bytes: 82600