akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int a;
  cin >> a;
  cout << a + (a*a) + (a*a*a) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	map<int, int> has;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		has[x]++;
	}
	for(int i = 0; i < m; i++){
		int b, c; cin >> b >> c;
		int tot = 0;
		while(!has.empty() && (*has.begin()).first <= c && tot < b){
			int now = (*has.begin()).second;
			int val = (*has.begin()).first;
			int tk = min(b - tot, now);
			tot += tk;
			has.erase(has.begin());
			if(now - tk > 0){
			       	has[val] += now - tk;
				break;
			}
		}
		has[c] += tot;
	}
	long long ans = 0;
	for(auto it : has) ans += 1ll * it.first * it.second;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int n;
string s;

string shift(string a, int c) {
	for(int i = 0; i < a.length(); ++i) {
		int b = (int)a[i] - (int)'A';
		b = (b + c) % 26;
		a[i] = (char)(b + (int)'A');
	}
	return a;
}

int32_t main() {
	cin >> n >> s;
	cout << shift(s, n);
}

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

int main() {
  int n, y;
  std::cin >> n >> y;
  
  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < n+1 - i; j++) {
      int k = n - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
        std::cout << i << " " << j << " " << k << "\n";
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<vector<ll>> li;
vector<ll> dp;

int input(){
  cin >> N;
  REP(i,N) {
    li.push_back( vector<ll>() );
    REP(j,N) li[i].push_back( inp<ll>() );
  }
}

ll ret(ll st){
 if (st==0) return 1;
 if (dp[st]>-1) return dp[st];
 ll su = 0l;
 ll co = 0;
 REP(i,N) co += (st>>i)&1;
 REP(i,N){
   ll t = 1<<i;
   if ((st&t)>0 & li[co-1][i]) {
     su += ret(st^t);
   }
 }
 
 dp[st] = su%(1000000007);
 return dp[st];
  
}

int main()
{
  input();
  
  REP(j,1l<<N) dp.push_back( -1 );
   
  
  cout << ret((1<<N)-1) << endl;
}

Measured memory_bytes: 18668
A,B,C,D,E,F=map(int,input().split())
max_dencity=0
best_sugarwater=100*A
best_sugar=0

max_A=F//(A*100)
for a in range(max_A+1):
    max_B=(F-100*A*a)//(B*100)
    for b in range(max_B+1):
        water=A*a+B*b
        max_sugar=min(F-water*100,water*E)
        max_c=max_sugar//C
        for c in range(max_c+1):
            max_d=(max_sugar-C*c)//D
            for d in range(max_d+1):
                sugar=C*c+D*d
                sugarwater=water*100+sugar
                if sugarwater==0:
                    pass
                elif sugar/(sugarwater) > max_dencity:
                    max_dencity=sugar/(sugarwater)
                    best_sugarwater=sugarwater
                    best_sugar=sugar
                    
                
print(best_sugarwater,best_sugar)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(void){
  char a[100],b[100],c[100];
  scanf("%s%s%s",a,b,c);
  int carda=strlen(a)-1,cardb=strlen(b)-1,cardc=strlen(c)-1;
  char index='a';
  int A=0,B=0,C=0,ans='A';
  while(1){
    if(index=='a'){
      index=a[A];
      ans='A';
      if(a[A]=='\0') break;
      A++;
    }
    else if(index=='b'){
      index=b[B];
      ans='B';
      if(b[B]=='\0') break;
      B++;
    }
    else if(index=='c'){
      index=c[C];
      ans='C';
      if(c[C]=='\0') break;
      C++;
    }
  }
  printf("%c",ans);
  return 0;
}

Measured memory_bytes: 128
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);

void solve() {
    int h,n;
    cin>>h>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        sum+=x;
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }
}
int32_t main() {
    IOS;
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	ll l, r;
	cin >> l >> r;
	ll rm = INF;
	ll lm = INF;
	if (r - l >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	ll res = INF;
	for (ll i = l; i <= r-1; i++) {
		lm = i % 2019;
		for (ll j = l + 1; j <= r; j++) {
			rm = j % 2019;
			chmin(res, (lm * rm) % 2019);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = []
c = []
flag = True
for i in range(n):
    if flag:
        b.append(a[i])
        flag = False
    else:
        c.append(a[i])
        flag = True
if flag:
    c.reverse()
    ans = c+b
else:
    b.reverse()
    ans = b+c
for i in range(n):
    print(ans[i], end=" ")
print()

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

class Edge{
public:
  int to,d,c;
};

int N,M,C,s,g;
vector<vector<Edge>> es;
vector<vector<int>> Q,R;
vector<int> p;
vector<vector<int>> fare;
long long distances[101][101];

int getFare(int d, int c){
  const vector<int>& q = Q[c];
  const vector<int>& r = R[c];

  if(r.size() == 1){
    return d * r[0];
  }
  // vector<int> q = {3,6};
  // vector<int> r = {10,5,3};
  if(d <= q[0])return d * r[0];
  int sum = q[0] * r[0];
  for(int i=1;i<q.size();i++){
    if(d <= q[i]){
      return sum + r[i]*(d - q[i-1]);
    } else {
      sum += r[i]*(q[i] - q[i-1]);
    }
  }
  return sum + r[r.size()-1]*(d-q[q.size()-1]);
}
void calcFare(){
  fare = vector<vector<int>>(C,vector<int>(20010));
  for(int i=0;i<C;i++){
    for(int d=1;d<20010;d++){
      fare[i][d] = getFare(d,i);
    }
  }
  // cerr << "calc fare end" << endl;
}

typedef pair<int,int> pii;
const long long INF = 1e10;
void bfs(int s,int c){
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.emplace(0,s);

  long long dist[101];
  for(int i=0;i<100;i++)
    dist[i] = INF;
  dist[s] = 0LL;
  while(!pq.empty()){
    int cost,v;
    tie(cost,v) = pq.top();pq.pop();
    for(Edge e : es[v]){
      if(e.c != c)continue;
      int nextCost = e.d + cost;
      if(dist[e.to] <= nextCost)continue;
      dist[e.to] = nextCost;
      pq.emplace(nextCost, e.to);
    }
  }
  // cerr << "search end" << endl;

  for(int i=0;i<N;i++){
    if(dist[i] == INF) continue;
    long long f = fare[c][dist[i]];
    distances[s][i] = min(distances[s][i],f);
    distances[i][s] = min(distances[i][s],f);
  }
}

int main(void) {

while(true){
  cin >> N >> M >> C >> s >> g;
  if(N+M+C+s+g == 0)return 0;
  s--;g--;
  es = vector<vector<Edge>>(N);
  for(int i=0;i<M;i++){
    int x,y,d,c;
    cin >> x >> y >> d >> c;
    x--;y--;c--;
    es[x].push_back(Edge{y,d,c});
    es[y].push_back(Edge{x,d,c});
  }

  p = vector<int>(C);
  for(int i=0;i<C;i++)
    cin >> p[i];

  Q = vector<vector<int>>(C);
  R = vector<vector<int>>(C);
  for(int i=0;i<C;i++){
    for(int j=0;j<p[i]-1;j++){
      int q;
      cin >> q;
      Q[i].push_back(q);
    }
    for(int j=0;j<p[i];j++){
      int c;
      cin >> c;
      R[i].push_back(c);
    }
  }
  calcFare();
  for(int i=0;i<C;i++){
    for(int j=1;j<=10;j++){
      // fprintf(stderr,"%4d ",fare[i][j]);
    }
    // cerr << endl;
  }

  for(int i=0;i<101;i++)for(int j=0;j<101;j++){
    if(i == j)distances[i][j] = 0;
    else distances[i][j] = INF;
  }

  for(int i=0;i<N;i++){
    for(int c=0;c<C;c++){
      bfs(i,c);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      // cerr << distances[i][j] << " ";
    }
    // cerr << endl;
  }

  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
      }
    }
  }
  if(distances[s][g] == INF)cout << -1 << endl;
  else cout << distances[s][g] << endl;
}
	return 0;
}

Measured memory_bytes: 6088
from bisect import bisect_left
A, B, Q = map(int, input().split())
minf, inf = -(10**18), 10**18
jinja = [minf] + list(map(int, (input() for _ in [0]*A))) + [inf]
tera = [minf] + list(map(int, (input() for _ in [0]*B))) + [inf]
ans = []
append = ans.append

for q in map(int, list(map(int, (input() for _ in [0]*Q)))):
    i = bisect_left(jinja, q)
    j = bisect_left(tera, q)
    left_jinja, right_jinja = q-jinja[i-1], jinja[i]-q
    left_tera, right_tera = q-tera[j-1], tera[j]-q
 
    append(min(
        left_jinja if left_jinja > left_tera else left_tera,
        left_jinja + right_tera + (left_jinja if left_jinja < right_tera else right_tera),
        right_jinja + left_tera + (right_jinja if right_jinja < left_tera else left_tera),
        right_jinja if right_jinja > right_tera else right_tera
    ))
 
print(*ans, sep="\n")

Measured memory_bytes: 19888
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,k,s;
    cin >> n >> k >> s;
    if(k == 0){
        if(s == 1e9){
            rep(i,n){
                cout << 1 << " ";
            }
            cout << endl;
            return 0;
        }else{
            rep(i,n){
                cout << 1000000000 << " ";
            }
            cout << endl;
            return 0;
        }
    }
    long g = n + 1 - k;
    if(g > s){
        rep(i,s-1+k) cout << 1 << " ";
        rep(i,n-(s-1+k)) cout << 1000000000 << endl;
        return 0;
    }
    int i = 0;
    while(i < n && g <= s){
        //long tmp = s;
        //long div = s / g;
        rep(j,g-1){
            //cout << div << " ";
            cout << 1 << " ";
            i++;
            //tmp -= div;
            if(i >= n) break;
        }
        if(i >= n) break;
        //cout << tmp << " ";
        cout << s - (g-1) << " ";
        i++;
        if(i >= n) break;
    }
    cout << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h> 
 
using namespace std; 
 
 
 
int main() 
{

  int H=1,W=1;
  
  while(H!=0&&W!=0){
    cin>>H>>W;
    
    if(H==0&&W==0)
      break;
    
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if((i+j)%2==0)
          cout<<'#';
        else
          cout<<'.';
      }
      cout<<endl;
    }
    cout<<endl;
  }
 
  return 0;
}


Measured memory_bytes: 3080
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, M;

    scanf("%zu %zu", &N, &M);

    const size_t cList[6] = { 1,2,4,8,16,32 };

    printf("%zu\n", (1900 * M + 100 * (N - M)) * cList[M]);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


char num[] = {'0','1','2','3','4','5','6','7','8','9'};
char mcxi[] = {'m','c','x','i'};
int mcxi2[] = {1000,100,10,1};


int sum[2];

int main(){


    int n;
    cin >> n;
    for(int iii = 0;iii < n;iii++){
        char inp[2][12];
        cin >> inp[0] >> inp[1];
        for(int k = 0;k < 2;k++){
            sum[k] = 0;
            for(int i = 0;i < strlen(inp[k]);i++){
                int flag = 0;
                for(int j = 2;j <= 9;j++){
                    if(num[j] == inp[k][i]){
                        flag = j;
                        break;
                    }
                }
                if(flag == 0){
                    flag = 1;
                }else{
                    i++;
                }
                for(int j = 0;j < 4;j++){
                    if(inp[k][i] == mcxi[j]){
                        sum[k] += flag * mcxi2[j];
                        break;
                    }
                }
            }
   //         cout << sum[k] << endl;
        }
        int s = sum[0] + sum[1];
        for(int i = 0;i < 4;i++){
            if(s / mcxi2[i] > 1) cout << s/mcxi2[i];
            if(s / mcxi2[i] >= 1) cout << mcxi[i];
            s %= mcxi2[i];
        }
        cout << endl;
        

    }
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



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

  reverse(s.begin(),s.end());
  //cout<<s<<endl;
  bool flag=true;

  for(int i=0;i<s.size();i++){
    if(s.substr(i,5)=="maerd"){
    //  cout<<s.substr(i,5)<<endl;
      i+=4;

    }
    else if(s.substr(i,7)=="remaerd"){
      i+=6;
    }
    else if(s.substr(i,6)=="resare"){
      i+=5;
    }
    else if(s.substr(i,5)=="esare"){
      i+=4;
    }
    else {flag=false;break;}
  }

  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;


  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,x;
  cin>>n>>x;
  vector<int> l(n);
  vector<long long int> d(n+1);
  d.at(0)=0;
  for(int i=0; i<n; i++){
    cin>>l.at(i);
    if(i>0){
      d.at(i)=d.at(i-1)+l.at(i-1);
    }
  }
  d.at(n)=d.at(n-1)+l.at(n-1);

  auto ans=upper_bound(d.begin(),d.end(),x);
  int a=ans-d.begin();
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// vector print(debug or stdout)
template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    int N; cin >> N;
    vector<int> v(N);
    int sumxor = 0;
    REP(i,N) {
        cin >> v[i];
        sumxor ^= v[i];
    }

    vector<int> ans;
    REP(i,N) {
        ans.push_back(sumxor ^ v[i]);
    }

    vout(ALL(ans),cout);

    return 0;
}

Measured memory_bytes: 4940
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b,c,d,e;
    cin >> a >> b >> c >>d>>e;
    if(a==0) cout << 1 << endl;
    else if(b==0) cout << 2 << endl;
    else if(c==0) cout << 3 <<endl;
    else if(d==0) cout << 4 <<endl;

    else cout << 5 << endl;

}

Measured memory_bytes: 3656
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

V kaitable,gyakutable;
ll sqMod(ll x){
  return 1LL*x*x%MOD;
}
ll powMod(ll x,ll n){//xのn乗
  if(n==0)return 1;
  else if(n==1)return x;
  if(n%2==0)return (sqMod(powMod(x,n/2)%MOD)%MOD);
  else return ((x*sqMod(powMod(x,n/2)%MOD)%MOD)%MOD);
}
ll combi(int n,int m){
  return 1LL * kaitable[n+m] * gyakutable[n] % MOD * gyakutable[m]% MOD;
}

int main(){
  CIN(h,w,a,b);
  kaitable = V(h+w);
  gyakutable = V(h+w);
  kaitable[0]=1;
  gyakutable[0]=1;
  FOR(i,1,h+w){
    kaitable[i] = 1LL * kaitable[i-1] * i % MOD;
    gyakutable[i] = powMod(kaitable[i],1e9+5)%MOD;
  }
  ll ans=0;
  FOR(i,b,w){
    ll pat = combi(h-a-1,i);
    ll pat2 = combi(a-1,w-1-i);
    ans += pat*pat2%MOD;
    ans%=MOD;
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);


		int x =scanner.nextInt();
		int n =scanner.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i=0 ; i<n ; i++) {
			list.add(scanner.nextInt());
		}
		scanner.close();

		int d = 0;
		while(true) {
			if(!list.contains(x-d)) {
				System.out.println(x-d);;
				break;
			}
			if(!list.contains(x+d)) {
				System.out.println(x+d);
				break;
			}
			d++;
		}

	}

}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	string s; cin >> s;
	int N = s.size();
	vector<int> T(N+1,0);
	vector<int> count_mod(2019,0);

	int pow_of_ten = 1;
	for (int i = N-1; i >= 0; i--) {
		T[i] += T[i+1] + (s[i] - '0') * pow_of_ten;
		T[i] %= 2019;
		pow_of_ten *= 10;
		pow_of_ten %= 2019;
	}

	for (int i = 0; i < N+1; i++) {
		count_mod[T[i]]++;
	}
	int ans = 0;
	for (int i = 0; i < 2019; i++) {
		ans += count_mod[i] * (count_mod[i]-1) / 2;	
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
	vector<int> a(3);
	for (int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	cout << a[0] + a[1] << endl;
	return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  int ans = 0;
  sort(L.begin(), L.end());
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int t = j + 1; t < N; t++) {
        if (L[i] != L[j] && L[j] != L[t] && L[i] != L[t]) {
          if (L[i] + L[j] > L[t]) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
# 各条件の入力
a, b, c = map(int, input().split())

# 答えの出力
import math

"""
素直にやると誤差で死ぬ
if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
    ans = 'Yes'
else:
    ans = 'No'
"""


# 整数でやる
left = a + b + (math.sqrt(a*b))*2
right = c

left2 = ((math.sqrt(a*b))*2) **2
right2 = (c - a - b) **2

left3 = 4*a*b
right3 = right2

if (c - a - b) < 0:
    ans = 'No'
elif left3 < right3:
    ans = 'Yes'
else:
    ans = 'No'

# 出力
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3624
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n;
int sol(int x){
            int r = (int)sqrt(1.0 * x);
            int sum = 0;
            if(r * r == x)
            {
                sum++;
                r--;
            }
            for(int i = 1; i <= r; i++)
            if(x % i == 0)
            {
                sum += 2;
            }
           return(sum);

}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i+=2){
		if(sol(i)==8)
		ans++;
	}
	cout<<ans;
	//system("pause");
	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S,h,m,s;
		S = sc.nextInt();
		h = S/3600;
		m = (S-h*3600)/60;
		s = S-h*3600-m*60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 17220
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000
y/=1000
for i in range(c+1):
    for j in range(n+1-i):
        k=n-i-j
        if i + 5*j + 10*k == y:
            print(k, j, i)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3064
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    println(maximum([a+b,a-b,a*b]))
end
main()

Measured memory_bytes: 111520
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;


int main(){
    stack<char> act;
    string S;
    cin >> S;
    for(int i=0;i<S.length();++i){
        if(S[i]=='B'){
            if(act.empty()==false){
            act.pop();
        }
    }
        else{
            act.push(S[i]);
        }
    }
    string W;
    while(act.empty()==false){
        W+=act.top();
        act.pop();
    }
    reverse(W.begin(),W.end());
    cout << W;
    cout << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string s, t;

  std::cin >> s >> t;

  int size1 = s.size(), size2 = t.size(), dp[3333][3333];

  memset(dp, -1, sizeof(dp));

  dp[0][0] = 0;

  for (int i = 0; i < size1; i ++)
    for (int j = 0; j < size2; j ++)
      if (dp[i][j] >= 0) {
        if (s[i] == t[j]) {
          dp[i + 1][j + 1] = std::max(dp[i][j] + 1, dp[i + 1][j + 1]);
        }
        else {
          dp[i + 1][j    ] = std::max(dp[i][j],     dp[i + 1][j    ]);
          dp[i    ][j + 1] = std::max(dp[i][j],     dp[i    ][j + 1]);
        }
      }

  int ip = -1, jp = -1, xp = -1;

  for (int i = 0; i <= size1; i ++)
    for (int j = 0; j <= size2; j ++)
      if (dp[i][j] >= xp)
        xp = dp[ip = i][jp = j];

  std::string r;

  for (int i = ip, j = jp, ii, jj; i && j; ) {
    if (dp[ii = i - 1][jj = j - 1] == dp[i][j] - 1 && s[ii] == t[jj]) {
      i = ii;
      j = jj;

      r.push_back(s[i]);
    }
    else if (dp[ii][j] == dp[i][j]) {
      i = ii;
    }
    else if (dp[i][jj] == dp[i][j]) {
      j = jj;
    }
  }

  std::reverse(ALL(r));

  std::cout << r << std::endl;

  return 0;
}


Measured memory_bytes: 43648
N,A,B,C=map(int,input().split())
l=[]
 
for i in range(N):
    l.append(int(input()))
INF=100000
 
def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  set<char> st;
  vector<i64> vec = {
    'q',
    'w',
    'e',
    'r',
    't',
    'a',
    's',
    'd',
    'f',
    'g',
    'z',
    'x',
    'c',
    'v',
    'b',
  };
  for(auto x: vec) st.insert(x);
  string s;
  while(cin >> s, s != "#") {
    i64 ans = 0;
    i64 bf = st.count(s.front());
    for(auto x: s) {
      ans += bf ^ st.count(x);
      bf = st.count(x);
    }
    cout << ans << endl;
  }
}



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

class Timer {
public:
    void start() {
        start_ = std::chrono::steady_clock::now();
    }
    int64_t elapsedMilliSec() {
        auto n = std::chrono::steady_clock::now();
        auto e = std::chrono::duration_cast<std::chrono::milliseconds>(n - start_);
        return e.count();
    }
private:
    std::chrono::steady_clock::time_point start_;
};

constexpr int64_t NUM = 26;
vector<int64_t> c(NUM);
vector<vector<int64_t>> s;

int64_t score(const vector<int64_t>& v) {
    vector<int64_t> last(NUM, -1);
    int64_t S = 0;
    for (int64_t i = 0; i < v.size(); i++) {
        //開催による満足度増加
        S += s[i][v[i]];

        //最終開催日更新
        last[v[i]] = i;

        //開催されないことによる満足度減少
        for (int64_t j = 0; j < NUM; j++) {
            S -= c[j] * (i - last[j]);
        }
    }

    return S;
}

int main() {
    //入力
    int64_t D;
    cin >> D;
    for (int64_t& C : c) {
        cin >> C;
    }

    s.resize(D, vector<int64_t>(NUM));
    for (int64_t i = 0; i < D; i++) {
        for (int64_t j = 0; j < NUM; j++) {
            cin >> s[i][j];
        }
    }

    //時間関連
    Timer timer;
    timer.start();
    constexpr int64_t LIMIT_MSEC = 1900;

    //乱数関連
    mt19937_64 engine(0);
    uniform_int_distribution<int64_t> day_dist(0, D - 1);
    uniform_int_distribution<int64_t> num_dist(0, NUM - 1);

    //初期化
    vector<int64_t> ans(D);
    vector<int64_t> last(NUM, -1);
    for (int64_t i = 0; i < D; i++) {
        vector<int64_t> scores(NUM);
        for (int64_t j = 0; j < NUM; j++) {
            scores[j] = - c[j] * (i - last[j]);
        }
        int64_t sum = accumulate(scores.begin(), scores.end(), (int64_t)0);
        for (int64_t j = 0; j < NUM; j++) {
            scores[j] = s[i][j] + c[j] * (i - last[j]) - sum;
        }

        ans[i] = max_element(scores.begin(), scores.end()) - scores.begin();

        //最終開催日更新
        last[ans[i]] = i;
    }

    int64_t best_score = score(ans);

    int64_t trial_num = 0, success = 0;
    while (timer.elapsedMilliSec() < LIMIT_MSEC) {
        trial_num++;

        int64_t curr_best_score = best_score;

        int64_t change_day = day_dist(engine);

        for (int64_t change_num = 0; change_num < NUM; change_num++) {
            //変える
            int64_t before_num = ans[change_day];
            ans[change_day] = change_num;

            int64_t curr_num = score(ans);

            if (curr_num > best_score) {
                best_score = curr_num;
            } else {
                //戻す
                ans[change_day] = before_num;
            }
        }

        if (best_score > curr_best_score) {
            success++;
        }
    }

    for (int64_t& a : ans) {
        cout << a + 1 << endl;
    }

    //cout << success << "/" << trial_num << " = " << (double)success / trial_num << endl;
}

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

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		int ch=ans*2;
		if(ch-ans>k) 
		{
			ans+=k;
		}
		else ans*=2;
	}
	cout<<ans<<endl;

}


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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 10000;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/

void solve(){

  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
    if(n%i==0){
      int x=n/i;
      if(x>=1&&x<=9){
        cout<<"Yes";
        return;
      }
    }
  }
  cout<<"No";
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>l(2*n);
  int i;
  for(i=0;i<2*n;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int sum = 0;
  for(i=0;i<n;i++){
    sum += l[2*i];
  }
  cout << sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1e9+7;


int main(void){
  int d[10] = {};
  int dd[100] = {};
  int ddd[1000] = {};
  int n;
  string s;
  cin >> n;
  cin >> s;
  for(int i = 0;i < n;++i){
    int c = s[i] - '0';
    for(int i = 0;i < 100;++i){
      if(dd[i]) ddd[i*10+c] = 1;
    }
    for(int i = 0;i < 10;++i){
      if(d[i]) dd[i*10+c] = 1;
    }
    d[c] = 1;
  }
  int res = 0;
  for(int i = 0;i < 1000;++i){
    if(ddd[i]){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
from math import ceil
def point(x,y,r,s,p):
    if y == 'r':
        y = p
    if y == 's':
        y = r
    if y == 'p':
        y = s
    return ceil(x/2) * y
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
ans = 0
for _ in range(k):
    l = t[_::k]
    x = 1
    y = l[0]
    for i in l[1:]:
        if i != y:
            ans += point(x,y,r,s,p)
            x = 1
            y = i
        else:
            x += 1
    ans += point(x,y,r,s,p)
print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n;
    cin >> n;
    vector<int> d(n), e(n);
    rep(i, n) cin >> d[i] >> e[i];

    bool ck = false;
    int num = 0;
    rep(i, n)
    {
        if (d[i] == e[i])
        {
            num++;
        }
        else
        {
            num = 0;
        }
        if (num >= 3)
        {
            ck = true;
        }
    }

    cout << (ck ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 610
bool vis[MX][MX];
int siz, d1, d2, bd;
void deal(R int dis)
{
    int tim = 0;
    W (!(dis % 4)) dis /= 4, ++tim;
    if(dis & 1)
    {
        for (R int i = 0; i < bd; ++i)
        for (R int j = 0; j < bd; ++j)
        if((i >> tim) + (j >> tim) & 1) vis[i][j] = true;
    }
    else
    {
        for (R int i = 0; i < bd; ++i)
        for (R int j = 0; j < bd; ++j)
        if((i >> tim) & 1) vis[i][j] = true;
    }
}
int main(void)
{
    scanf("%d%d%d", &siz, &d1, &d2);
    bd = siz << 1; deal(d1), deal(d2);
    int tar = siz * siz, cnt = 0;
    for (R int i = 0; i < bd; ++i)
    for (R int j = 0; j < bd; ++j)
    {
        if(!vis[i][j]) printf("%d %d\n", i, j), cnt++;
        if(cnt == tar) return 0;
    }
}

Measured memory_bytes: 1152
n = int(input())
a = [int(input()) for i in range(n)]
sorted_list = sorted(a, reverse=True)
a_max = sorted_list[0]
a_sec = sorted_list[1]
for i in range(n) :
    if a[i] != a_max :
        print(a_max)
    else :
        print(a_sec)


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int max3(int a, int b, int c)
{
    return max(a,max(b,c));
}
int main()
{
  int n;
  cin>>n;
  int a[n], b[n], c[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i]>>b[i]>>c[i];
  }
  int A[n], B[n], C[n];
  A[0]=a[0];
  B[0]=b[0];
  C[0]=c[0];
  if(n>1)
  {
      A[1]=max(A[0],a[1]+max(B[0],C[0]));
      B[1]=max(B[0],b[1]+max(A[0],C[0]));
      C[1]=max(C[0],c[1]+max(A[0],B[0]));
  }
  for(int i=2;i<n;i++)
  {
     A[i]=max(A[i-2],a[i]+max3(B[i-1],C[i-1],A[i-2]));
     B[i]=max(B[i-2],b[i]+max3(A[i-1],C[i-1],B[i-2]));
     C[i]=max(C[i-2],c[i]+max3(B[i-1],A[i-1],C[i-2]));
  }
 // for(int i=0;i<n;i++)
  cout<<max3(A[n-1],B[n-1],C[n-1])<<"\n";
    return 0;
}

Measured memory_bytes: 2560
import itertools

n = int(input())
l = list(map(int, input().split()))
cnt = 0

L = []

for i in itertools.combinations(l, 3):
    if len(set(i)) == 3 and (i[0]+i[1] > i[2]) and (i[1]+i[2] > i[0]) and (i[2]+i[0] > i[1]):
        L.append(i)

print(len(L))

Measured memory_bytes: 82160
// D - I hate Factorization
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 素数と個数を求める
vector<pair<ll,ll>> factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2L; i*i<=n; ++i){
    if (n%i) continue;
		ll c = 0;
    while(n%i == 0){ n /= i; c++; }
    res.emplace_back(i,c);
  }
  if(n != 1) res.emplace_back(n,1L);
  return res;
}

int main(){
	ll X; cin>>X;
	for(ll a=-200; a<=200; ++a){ // [-200,200]
		ll b5 = a*a*a*a*a - X, sign = 1;
		if(b5 < 0){ b5 = -b5; sign = -1; }
		vector<pair<ll,ll>> pc = factorize(b5);
		ll b = b5 != 0;
		for(auto x:pc) if(x.second == 5) b *= x.first; else break;
		if(b*b*b*b*b == b5){ cout<<a<<" "<<sign*b<<endl; break; }
	}
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i=0; i<n; i++) cin >> a[i];
    b = a;
    sort(b.begin(), b.end());

    double mid = b[n/2-1] + b[n/2];
    mid /= 2;
    for (int i=0; i<n; i++) {
        int ans =0;
        if (a[i] <= mid) ans = b[n/2];
        else ans = b[n/2-1];

        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll x;

void Input() {
	cin >> x;
}

void Solve() {
	if (x >= 400 and x < 600)cout << 8;
	else if (x >= 600 and x < 800)cout << 7;
	else if (x >= 800 and x < 1000)cout << 6;
	else if (x >= 1000 and x < 1200)cout << 5;
	else if (x >= 1200 and x < 1400)cout << 4;
	else if (x >= 1400 and x < 1600)cout << 3;
	else if (x >= 1600 and x < 1800)cout << 2;
	else if (x >= 1800 and x < 2000)cout << 1;
}

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

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

typedef long long ll;

// ユークリッドの互除法
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; }

int f(int x){
  int count=0;
  while(x%2 == 0){
    x = x/2;
    count++;
  }
  return count;
}


int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  rep(i,n){
    cin >> a[i];
    a[i] = a[i] / 2;
  }
  
  int ans=-1;
  ll l=1;
  int factor2=f(a[0]);
  rep(i,n){
    if( f(a[i]) != factor2 ){
      ans = 0;
      break;
    }else{
      l = lcm( l, a[i] );
    }
  }
  
  if(ans != 0){
    ans = (m/l + 1)/2 ;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

// const long long INF = 1LL << 60;

// Warshall-Floyd
// O(V^3)

// 最終的にiからjの最小コストはcost[i][j]となる。
vvll cost;

void init(ll V, vvll& cost) {
  cost = vvll(V, vll(V, INF));
  rep(i, V) {
    // 自分自身へ移動するコストは0
    cost[i][i] = 0;
  }

  // edgeを引く
  // 例: iからjにコストcの辺を引く
  // d[i][j] = c
}

void warshall_floyd(ll V, vvll& cost) {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
}

ll n;
vector<string> s;
vb used;

ll dfs(ll depth, set<ll>& v) {
  set<ll> next_v;

  for (auto it : v) {
    used[it] = true;
  }

  for (auto it : v) {
    rep(i, n) {
      if (s[it][i]) {
        if (used[i])
          return -1;
        next_v.insert(i);
        s[it][i] = 0;
        s[i][it] = 0;
      }
    }
  }

  if (next_v.size() == 0) {
    return depth;
  }

  return dfs(depth + 1, next_v);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cin >> n;

  s = vector<string>(n);
  used = vb(n);

  rep(i, n) {
    cin >> s[i];
  }

  rep(i, n) {
    rep(j, n) {
      s[i][j] -= '0';
    }
  }

  cost = vvll(n, vll(n, INF));
  rep(i, n) {
    // 自分自身へ移動するコストは0
    cost[i][i] = 0;
  }

  rep(i, n) {
    rep(j, n) {
      if (s[i][j]) {
        cost[i][j] = 1;
      }
    }
  }

  warshall_floyd(n, cost);
  ll diameter = 0;
  ll far_idx = 0;
  rep(i, n) {
    rep(j, n) {
      if (diameter < cost[i][j]) {
        diameter = cost[i][j];
        far_idx = i;
      }
    }
  }

  set<ll> v;
  rep(i, n) {
    if (cost[far_idx][i] == diameter) {
      v.insert(i);
    }
  }

  if (dfs(1, v) == -1) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = diameter + 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3980