akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int n;
    string s = "0123456789543210123456789543210123456789543210";
    cin >> n;
    for(int i=0;i<n;i++){
	char a,b;
	cin >> a >> b;
	int m = (int)(a - '0');
	int l = (int)(b - '0');
	if(0<= m && m  <= 5 && 0<= l && l <= 5){
	    if(m < l){
		cout << m;
		for(int i=m+1;i<=l;i++){
		    cout << " " << i;
		}
		cout << endl;
	    }else{
		cout << m;
		for(int i=m-1;i>=l;i--){
		    cout << " " << i;
		}
		cout << endl;
	    }
	    continue;
	}
	int x = 0;
	cout << a;
	while(s[x] != a) x++;
	while(s[x] != b){
	    x++;
	    cout << " "<< s[x];
	}
	cout << endl;

    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	int Maxi = 0;
	int ans = 0;
	rep(i, n) {
		int x;
		cin >> x;
		if (Maxi == x) ans++;
		if (chmax(Maxi, x)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3556
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class ATakAndHotelsABCEdit {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, k, x, y; in >> n >> k >> x >> y;
	    ll ans = 0ll;
	    ans += min(n, k)*x;
	    n -= min(n,k);
	    if (n < 0) n = 0;
	    ans += y*n;
	    out << ans << el;
	}
};


int main() {
	ATakAndHotelsABCEdit solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int top,s[1000];//这个数组是用来建立栈的 

void push(int x)
{
	s[++top]=x;	
} 

int pop()
{
	top--;
	return s[top+1];//出栈的同时抛出栈顶元素 
}

int main()
{
	int a,b;
	top=0;
	char str[100];//这个数组是用来存储输入数据的
	while(~scanf("%s",str)){
		switch(str[0]){
			case'+':{
				a=pop();
				b=pop();
				push(a+b);
				break;
			}
			case'-':{
				a=pop();
				b=pop();
				push(b-a);
				break;
			}
			case'*':{
				a=pop();
				b=pop();
				push(a*b);
				break;
			}
			case'/':{
				a=pop();
				b=pop();
				push(b/a);
				break;
			}
			default:{
				push(atoi(str));
				break;
			}
		}
	} 
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ld long double
#define ss second
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384626
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)

const int mod = 1'000'000'007;

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


	
int main()
{
		fastio;
		ll t = 1;
		//cin >> t;
		rep(tt,1,t+1)
		{
			ll n, m;
			cin >> n >> m;
			vector<vll> dp(n, vll(m));
			vector<string> A(n);
			rep(i, 0, n)
			{
					cin >>A[i];
			}
			dp[0][0] = 1;
			rep(i, 0, n)
			{ 
				rep(j, 0, m)
				{
					if(A[i][j] == '.')
					{
					if(i+1 < n)
					{
						dp[i+1][j] += dp[i][j]%mod;
						dp[i+1][j]%=mod;
					}	
					if(j+1 < m)
					{
						dp[i][j+1] += dp[i][j]%mod;
						dp[i][j+1]%=mod;
					}
					}
				}
			}
			cout << dp[n-1][m-1]%mod<<endl;
		}
		return 0;
	}
				


Measured memory_bytes: 12440
n,k,*a=map(int,open(0).read().split())
z=sorted(a[:n]),sorted(a[n:])[::-1]
o=10**12
g=-1
while o-g>1:
 m,l=o+g>>1,k
 for a,f in zip(*z):l-=max(0,a-m//f)
 if l<0:g=m
 else:o=m
print(o)

Measured memory_bytes: 128056
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = 1 << 25;
	for(int i = -100; i <= 100; i++){
		int tmp = 0;
		for(int j = 0; j < n; j++){
			tmp += (i - a[j]) * (i - a[j]);
		}
		if(tmp < ans) ans = tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main()
{
	char day[10];

	scanf("%s", day);

	if (strcmp(day,"SUN")==0)
		printf("7\n");
	else if (strcmp(day, "MON") == 0)
		printf("6\n");
	else if (strcmp(day, "TUE") == 0)
		printf("5\n");
	else if (strcmp(day, "WED") == 0)
		printf("4\n");
	else if (strcmp(day, "THU") == 0)
		printf("3\n");
	else if (strcmp(day, "FRI") == 0)
		printf("2\n");
	else if (strcmp(day, "SAT") == 0)
		printf("1\n");

	return 0;
}

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

int main() {
  int n;
  bool a=false;
  cin >> n;
  
  for(int i=1;i<=9;i++){
      if(n%i==0 && n/i<10){a=true;}
  }
  if(a==true){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}


Measured memory_bytes: 256
import itertools
import math

def culc(o):
  time = o[0]
  for i in o[1:]:
    time = math.ceil(time / 10) * 10
    time += i
  return time

d = []
for i in range(5):
  d.append(int(input()))

p = list(itertools.permutations(d))
time = [culc(i) for i in p]

print(min(time))

Measured memory_bytes: 3064
// https : //onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/2/ITP2_2_C

#include <iostream>
#include <vector>
#include <queue>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::priority_queue<int>> qu(n);

    int m, t, x;
    for (int i = 0; i < q; i++)
    {
        std::cin >> m >> t;
        if (m == 0)
        {
            std::cin >> x;
            qu[t].push(x);
        }
        else if (m == 1)
        {
            if (qu[t].size() > 0)
            {
                //デフォルトで大きい順に並んでいる
                std::cout << qu[t].top() << std::endl;
            }
        }
        else if (m == 2)
        {
            if (qu[t].size() > 0)
            {
                qu[t].pop();
            }
        }
    }
}


Measured memory_bytes: 4092
#include<stdio.h>

int i,j,k,w,n,x,y,z,ans[50];

int main(){
    scanf("%d",&w);
    for(i=1;i<=w;i++)ans[i]=i;
    scanf("\n%d",&n);
    for(i=0;i<n;i++){
        scanf("\n%d,%d",&x,&y);
        z=ans[x];
        ans[x]=ans[y];
        ans[y]=z;
    }
    for(i=1;i<=w;i++)printf("%d\n",ans[i]);
    
    return 0;
}				



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int i=0;
    while(2*i<s.size()){
        if(s.at(2*i)!='R'&&s.at(2*i)!='U'&&s.at(2*i)!='D'){
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    i=0;
    while((2*i+1)<s.size()){
        if(s.at(2*i+1)!='L'&&s.at(2*i+1)!='U'&&s.at(2*i+1)!='D'){
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main(void) {
	long long int A, B, n = 0;
	long long int res = 0;
	scanf("%lld%lld%lld", &n, &A, &B);
	if ((n % (A + B) <= A)) {
		res = (n / (A + B)) * A + (n % (A + B));
	}
	else {
		res = (n / (A + B)) * A + A;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//


int main() {

		fast_cin();

		ll n;
		cin >> n;
		vl arr(n);
		map<ll, ll> map;
		fo(i, n){ cin>> arr[i];}
		
		ll last = 0;
		ll count = 0;
		
		for (int i = 0; i < n; ++i) {
			if (arr[i] == last + 1) {
				count++;
				last += 1;
			}
		}
		
		if (count) {
			cout << n - count << endl;
		}else 
		cout << -1 << endl;
		

    return 0;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N; cin >> N;
    
    ll ans = INF;
    FOR(i, 1, N) {
        ll A = i;
        ll B = N - A;
        
        ll sum = 0;
        while (A > 0) sum += A % 10, A /= 10;
        while (B > 0) sum += B % 10, B /= 10;
        ans = min(ans, sum);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
#define MOD 1000000007
using namespace std;
typedef vector<int > vi;
typedef long long ll;
typedef vector<ll> vll;

bool isprime(ll a) {
	for (int i = 2; i < a; i++) {
		if (a%i == 0)return false;
	}
	return true;
}

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	for (ll i = 2; i <= n; i++) {
		if (isprime(i)) {
			//cout << i;
			ll x = n;
			ll p = 0;
			while (x > 0) {
				x = x / i;
				p += (x);
			}
			ans =(ans* (p+1))%MOD;
		}
	}
	cout << ans%MOD << endl;
}

Measured memory_bytes: 764
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    const long Mod = (long)1e9 + 7;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        var accum = new long[seqA.Length + 1];
        for (int i = 1; i < accum.Length; ++i)
        {
            accum[i] = (accum[i - 1] + seqA[i - 1]) % Mod;
        }

        var sum = 0L;
        for (int i = 1; i < accum.Length; ++i)
        checked
        {
            sum += seqA[i - 1] * ((accum[^1] - accum[i] + Mod) % Mod) % Mod;
            sum %= Mod;
        }

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 49252
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
int F[101]={};
int P[101][11]={};

int main() {
	cin>>N;
	int f1;
	for(int j=0;j<N;++j){
		for(int i=1;i<(1<<10);i=i<<1){
			cin>>f1;
			F[j]+=f1*i;
		}
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<11;++j){
			cin>>P[i][j];
		}
	}
	int total=-1000000001;

	for(int i=1;i<(1<<10);++i){
		int sum=0;
		for(int j=0;j<N;j++){
			int x=F[j]&i;
			int k=0;
			for(int m=1;m<(1<<10);m=m<<1){
				if((x&m)==m)k++;
			}
			sum+=P[j][k];
		}
		total=max(total,sum);
	}


	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <cstdlib>
#include <map>

using namespace std;
typedef pair<int,pair<int,int> > P;
typedef long long ll;

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

int w[2],h[2],x[2],y[2];
int r;
int field[2][501][501];
bool passed[501][501];
map<ll,int> visitableRooms[2];

int INF=1000000000;

void bfs(int k,int sx,int sy){
    // FØx1©çÔÉTõ
    priority_queue<P,vector<P>,greater<P> > pq;
    pq.push(make_pair(1,make_pair(sy,sx)));
    // »ÝÌx
    ll cL=0;
    // Kê½®Ì
    int sum=0;
    passed[sy][sx]=true;
    while(pq.size()){
        P p=pq.top();
        pq.pop();
        ll level=p.first;
        int cx=p.second.second;
        int cy=p.second.first;
        sum++;
        // »ÝÌxðXV·éKvª êÎAXV·é
        if(level>cL)
            cL=level;
        visitableRooms[k][cL]=sum;
        for(int i = 0; i < 4; i++){
            int ny=cy+dy[i];
            int nx=cx+dx[i];
            if(ny>=0&&nx>=0&&ny<h[k]&&nx<w[k]&&!passed[ny][nx]){
                pq.push(P(field[k][ny][nx],make_pair(ny,nx)));
                passed[ny][nx]=true;
            }
        }
    }
    if(visitableRooms[k].find(cL)==visitableRooms[k].end())
        visitableRooms[k][cL]=sum;
}

int main(){
    while(cin>>r&&r!=0){
        for(int k = 0; k < 2; k++){
            visitableRooms[k].clear();
            cin>>w[k]>>h[k]>>x[k]>>y[k];
            x[k]--;y[k]--;
            for(int i = 0; i < h[k]; i++)
                for(int j = 0; j < w[k]; j++)
                    cin>>field[k][i][j];
        }
        for(int k = 0; k < 2; k++){
            visitableRooms[k][0]=0;
            memset(passed,0,sizeof(passed));
            bfs(k,x[k],y[k]);
        }
        map<ll,int>::iterator ait=visitableRooms[0].begin();
        map<ll,int>::iterator bit=visitableRooms[1].end();
        bit--;
        int minLevelSum=INF;
        // »ê¼êÌiteratorð®©·
        while(1){
            int roomSum=(ait->second)+(bit->second);
            if(roomSum>=r){
                minLevelSum=min(minLevelSum,(int)(ait->first+bit->first));
                if(bit==visitableRooms[1].begin())
                    break;
                bit--;
            }
            else{
                ait++;
                if(ait==visitableRooms[0].end())
                    break;
            }
        }
        cout<<minLevelSum<<endl;
    }
    return 0;
}

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

int main(){
	string s;
	string yaki = "YAKI";
	string yakj = "YAKJ";
	cin >> s;
	if(yaki.compare(s) <= 0 && s.compare(yakj) < 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

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

using namespace std;
using namespace atcoder;

using mint=modint998244353;

mint ten[2000001];

using S=pair<mint,int>;
using F=int;
S op(S x,S y){
	return make_pair(x.first*ten[y.second]+y.first,x.second+y.second);
}
S e(){ return make_pair(mint(0),0); }
S mapping(F f,S x){
	if(f==0){
		return x;
	}
	else{
		int len=x.second;
		return make_pair((ten[len]-1)/9*f,len);
	}
}
F composition(F f,F g){ return f==0?g:f; }
F id(){ return 0; }

int main(){
	int n,q; scanf("%d%d",&n,&q);

	ten[0]=1;
	rep(i,n) ten[i+1]=ten[i]*10;

	lazy_segtree<S,op,e,F,mapping,composition,id> ST(n);
	rep(i,n) ST.set(i,make_pair(mint(1),1));

	rep(i,q){
		int l,r,d; scanf("%d%d%d",&l,&r,&d); l--;
		ST.apply(l,r,d);
		printf("%d\n",ST.all_prod().first.val());
	}

	return 0;
}


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

int main() {
    long long X;
    long long K;
    long long D;
    cin >> X >> K >> D;
    
    long long ans;
    if(X<0) X=-X;
    long long m;
    m=floor(X/D);
    m=min(K,m);
    K=K-m; X=X-m*D;
    if(K%2==0) ans=X;
    else ans=D-X;
    cout << ans << endl;

    }
  


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n+1), b(n);
	cin>>a>>b;
	ll ans=0;
	rep(i,n){
		if(a[i]>0){
			if(b[i]>=a[i]){
				ans+=a[i];
				b[i]-=a[i];
			}else{
				ans+=b[i];
				b[i]=0;
			}
		}
		if(b[i]>0){
			if(a[i+1]>0){
				ans+=min(a[i+1],b[i]);
				a[i+1]-=min(a[i+1],b[i]);
			}
		}
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    // 文字列の入力
    string s;
    cin >> s;
    // 出力
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}





int main(void){
   int N,A[200000],i,B[200000],max,nmax;
   scanf("%d",&N);
   for(i=0;i<N;i++){
      scanf("%d",&A[i]);
      B[i]=A[i];
   }
   quick_sort(A,0,N-1);
   max=A[N-1];
   nmax=A[N-2];
   for(i=0;i<N;i++){
      if(B[i]==max){
         printf("%d\n",nmax);
      }else{
      printf("%d\n",max);
   }
   }

   
   return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
vector<ll> A;
vector<string> OP;
ll memo[100000][3];
bool visited[100000][3];
ll f(int p, int q) {
	if (q < 0 || q >= 3) return -(1LL << 60);
	if (p == N) return 0;
	if (visited[p][q]) return memo[p][q];
	visited[p][q] = true;
	int qq = q;
	if (OP[p] == "-") ++qq;
	return memo[p][q] = max(f(p + 1, qq), f(p + 1, qq-1)) + (qq % 2 == 0 ? A[p] : -A[p]);
}
int main() {
	cin >> N;
	A.resize(N);
	OP.resize(N);
	OP[0] = "+";
	for (int i = 0; i < N; ++i) {
		if (i) cin >> OP[i];
		cin >> A[i];
	}
	cout << f(0, 0) << endl;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k,a,b[100]={};
    int ans=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a;
            b[a]++;
        }
    }
    for(int i=1;i<=m;i++){
        if(b[i]==n){
            ans++;
        }
    } 
    cout<<ans<<endl;
    return(0);
}

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

int main(){
  int h,w,i,j;
  cin>>h>>w;
  string s[h];
  for(i=0;i<h;i++){
    cin>>s[i];
  }
  char cnt;
  string p[h];
  for(i=0;i<h;i++){
	  p[i]="";
	  for(j=0;j<w;j++){
		  p[i]+='#';
	  }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='.'){
        cnt='0';
        if(i!=0){
          if(s[i-1][j]=='#')cnt++;
        }
        if(i!=h-1){
          if(s[i+1][j]=='#')cnt++;
        }
        if(j!=0){
          if(s[i][j-1]=='#')cnt++;
        }
        if(j!=w-1){
          if(s[i][j+1]=='#')cnt++;
        }
        if(i!=0 && j!=0){
          if(s[i-1][j-1]=='#')cnt++;
        }
        if(i!=h-1 && j!=w-1){
          if(s[i+1][j+1]=='#')cnt++;
        }
        if(i!=h-1 && j!=0){
          if(s[i+1][j-1]=='#')cnt++;
        }
        if(i!=0 && j!=w-1){
          if(s[i-1][j+1]=='#')cnt++;
        }
		p[i].replace(j,1,1,cnt);
      }
    }
  }
  for(i=0;i<h;i++){
    cout<<p[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <utility>

using namespace std;

struct edge_t {
  int target;
  int a, b;
};

vector<vector<edge_t>> graph;

int main() {
  int n, m, s, t;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  s--, t--;
  graph.resize(n);
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    scanf("%d%d%d%d", &u, &v, &a, &b);
    u--, v--;
    edge_t forward, backward;
    forward.a = a;
    forward.b = b;
    forward.target = v;
    graph[u].push_back(forward);
    backward.a = a;
    backward.b = b;
    backward.target = u;
    graph[v].push_back(backward);
  }
  vector<long long> dist_yen(n, LLONG_MAX), dist_snuke(n, LLONG_MAX);
  {
    vector<char> visit(n);
    priority_queue<pair<long long, int>> pq;
    dist_yen[s] = 0;
    pq.push(make_pair(0, s));
    while (!pq.empty()) {
      auto top = pq.top(); pq.pop();
      int cur = top.second;
      if (visit[cur]) continue;
      visit[cur] = 1;
      long long dist = -top.first;
      for (const auto &edge : graph[cur]) {
        int next = edge.target;
        if (visit[next]) continue;
        if (dist_yen[next] > dist + edge.a) {
          dist_yen[next] = dist + edge.a;
          pq.push(make_pair(-(dist + edge.a), next));
        }
      }
    }
  }
  {
    vector<char> visit(n);
    priority_queue<pair<long long, int>> pq;
    dist_snuke[t] = 0;
    pq.push(make_pair(0, t));
    while (!pq.empty()) {
      auto top = pq.top(); pq.pop();
      int cur = top.second;
      if (visit[cur]) continue;
      visit[cur] = 1;
      long long dist = -top.first;
      for (const auto &edge : graph[cur]) {
        int next = edge.target;
        if (visit[next]) continue;
        if (dist_snuke[next] > dist + edge.b) {
          dist_snuke[next] = dist + edge.b;
          pq.push(make_pair(-(dist + edge.b), next));
        }
      }
    }
  }

  vector<long long> ans(n);
  for (int i = 0; i < n; i++) {
    long long cur = 1000000000000000ll;
    cur -= dist_yen[i];
    cur -= dist_snuke[i];
    ans[i] = cur;
  }
  for (int i = n - 2; i >= 0; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (int i = 0; i < n; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 10696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

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

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int fib(int n){
	int dp[1000];
	fill_n(dp, 1000, 0);
	dp[0] = 1;
	dp[1] = 1;
	for(int i = 2; i < n; i++){
		dp[i] = dp[i-1] + dp[i-2];
	}
	return dp[n-1];
}

int main(void){
	int n;
	cin >> n;
	FIN(fib(n+1));
	return 0;
}

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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int n, m, k;
ll f[N];

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  f[0] = 1;
  for(int i = 1; i < N; ++i)
    f[i] = i*f[i-1]%M;

  cin >> n >> m;

  ll ans = 0;
  if(abs(n-m) < 2) {
    ans = f[n]*f[m]%M;
    if(n==m)
      ans = ans*2%M;
  }

  cout << ans << endl;
}

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

using namespace std;
int main() {
	int n, limit; cin >> n >> limit;
	vector<long long>dp(limit + 1); for (int i = 1; i <= limit; i++)dp[i] = -1145141919810931;
	for (int i = 0; i < n; i++) {
		int w, v; cin >> w >> v;
		for (int j = limit; j >= w; j--)dp[j] = max(dp[j], dp[j - w] + v);
	}
	long long ret = 0;
	for (int i = 0; i <= limit; i++)ret = max(ret, dp[i]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAGIC = 4 * 1000 * 1000 + 1;

typedef bitset<MAGIC> lst;

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  lst res;
  res.set(0);

  int n;
  scanf("%d", &n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    res |= (res << a);
    s += a;
  }

  s = (s + 1) / 2;
  while (!res.test(s)) s++;
  printf("%d\n", s);
  return 0;
}


Measured memory_bytes: 1664
using System;

namespace AOJ.Volume0
{
    public class SimultaneousEquation
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                var data = input.Split(' ');

                double a, b, c, d, e, f;
                a = double.Parse(data[0]);
                b = double.Parse(data[1]);
                c = double.Parse(data[2]);
                d = double.Parse(data[3]);
                e = double.Parse(data[4]);
                f = double.Parse(data[5]);
                // クラメールの公式で解を求める
                // 解がないケースは問題に記述がないので考慮しない
                double v1 = (a * e) - (b * d);
                double x = ((c * e) - (b * f)) / v1;
                double y = ((a * f) - (c * d)) / v1;
                // 四捨五入
                x += 0.0005d;
                y += 0.0005d;
                x = Math.Floor(x * 1000) / 1000;
                y = Math.Floor(y * 1000) / 1000;

                Console.WriteLine(string.Format("{0:f3} {1:f3}", x, y));
            }
        }
    }
}

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2!=0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int flag=1;
    int m=n/2;
    for(int i=0; i<n/2; i++)
    {
        if(s[i]!=s[m])
        {
            flag=0;break;
        }
        m++;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <set>

using namespace std;

const int L = 10;
struct dist {
	int s, N[L];
	dist() :s(100) {
		for (int i = 0; i < L; i++)
			N[i] = !i;
	}
	dist(const dist &p, int i) :s(p.s + i) {
		//if (*p.N < 0) {
		//	*N = -1;
		//	return;
		//}
		//int k = i;
		//for (int j = 0; j < L; j++) {
		//	N[j] = i ? p.N[j] + k : p.N[j] * 10 + k;
		//	k = N[j] / 100000000;
		//	N[j] %= 100000000;
		//}
		//if (k) *N = -1;
	}
	bool operator<(const dist &d) const {
		if (s != d.s)
			return s < d.s;
		//if (*N < 0)
		//	return false;
		//else if (*d.N < 0)
		//	return true;
		//for (int i = L; i--;)
		//	if (N[i] != d.N[i])
		//		return N[i] < d.N[i];
		return false;
	}
} d[114514];

struct vert {
	int r;
	vert(int r) :r(r) {}
	bool operator<(const vert &v) const {
		if (d[r] < d[v.r])
			return true;
		if (d[v.r] < d[r])
			return false;
		return r < v.r;
	}
};

int main()
{
	int k;
	cin >> k;
	d[1].s = 1;
	set<vert> q;
	q.insert(1);
	while (!q.empty()) {
		int u = q.begin()->r;
		q.erase(q.begin());
		for (int i = 0; i < 2; i++) {
			int v = (i ? u + 1 : u * 10) % k;
			dist l(d[u], i);
			if (!(l < d[v]))
				continue;
			auto it = q.find(v);
			if (it != q.end())
				q.erase(it);
			d[v] = l;
			q.insert(v);
		}
	}
	cout << d->s << endl;
	//if (*d->N < 0) {
	//	cout << "inf" << endl;
	//	return 0;
	//}
	//for (int i = L; i--;) {
	//	if (!k) {
	//		cout.fill('0');
	//		cout.width(8);
	//		cout << right << d->N[i];
	//	}
	//	else if (d->N[i]) {
	//		k = 0;
	//		cout << d->N[i];
	//	}
	//}
	//cout << endl;
	return 0;
}


Measured memory_bytes: 7424
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var h = o.r(n);
  h.sort((a,b)=>a-b);
  var ans = 9e9;
  for(var i = k - 1; i < n; i++){
    var t = h[i] - h[i-k+1];
    if(t < ans)ans = t;
  }
  return ans;
}

Measured memory_bytes: 28752
#include <iostream>

using namespace std;

int N,A,B;

int main()
{
	cin >> N >>A>>B;
	int AT;
	int s;
	AT = A * N;
	if (AT >= B) {
		cout << B << endl;
	}
	else {
		cout << AT << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define N 105
int n,cnt;
int graph[N][N];
int ans1[N],ans2[N];
bool checked[N];
void dfs(int i){
    if(checked[i]) return;
    checked[i] = true;
    ans1[i] = cnt++;
    for(int j = 0; j < n; j++){
        if(graph[i][j]) dfs(j);
    }
    ans2[i] = cnt++;
}

signed main() {
    cin >> n;
    for(int i = 0; i < n; i++){
        int a,b,c;
        cin >> a >> b;
        a--;
        for(int j = 0; j < b; j++){
            cin >> c;
            c--;
            graph[a][c] = 1;
        }
    }

    cnt = 1;
    for(int i = 0; i < n; i++){
        if(!checked[i]) dfs(i);
    }
    for(int i = 0; i < n; i++){
        cout << i + 1 << " " << ans1[i] << " " << ans2[i] << endl;
    }
}



Measured memory_bytes: 3204
import queue,sys
# 解説読んだ後
N,M=map(int,input().split())
# networkを作る
G={}
LRD=[]
for i in range(1,N+1):
    G[i]={}
for i in range(M):
    l,r,d=map(int,input().split())
    LRD.append((l,r,d))
    G[l][r]=d
    G[r][l]=-d
if M==0:
    print("Yes")
    sys.exit()
notvisit=set(range(1,N+1))
Q=queue.Queue()
x={}
while notvisit:
    current=notvisit.pop()
    Q.put(current)
    x[current]=0
    while Q.qsize():
        nex=Q.get()
        for k,v in G[nex].items():
            if k in x:
                if x[k]!= x[nex]+G[nex][k]:
                    print("No")
                    sys.exit()
            else:
                x[k]=x[nex]+G[nex][k]
                Q.put(k)
                notvisit.remove(k)
print("Yes")

Measured memory_bytes: 105416
#include <iostream>
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;
#define INF 1000000
typedef pair<int,int> P;

int H,W,N,i,j,minute;
char field[1000][1000];
P factory[10];

int solve(int i){
	queue<P> s;
	P now;
	int dist[H][W];
	for(int k=0;k<H;k++){
		for(int j=0;j<W;j++){
			dist[k][j]=INF;
		}
	}
	int x[4]={1,0,-1,0},y[4]={0,1,0,-1};
	dist[factory[i].first][factory[i].second]=0;
	s.push(factory[i]);
	while(!s.empty()){
		now=s.front(); s.pop();
		if(now == factory[i+1]) break;
		for(int k=0;k<4;k++){
			int nx=now.first+x[k],ny=now.second+y[k];
			if(0<=nx && nx<H && 0<=ny && ny<W && field[nx][ny]!='X' && dist[nx][ny] == INF){
				s.push(P(nx,ny));
				dist[nx][ny] = dist[now.first][now.second]+1;
			}
		}
	}
	return dist[now.first][now.second];
}

int main(){
	cin>>H>>W>>N;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cin>>field[i][j];
			if(1<=field[i][j]-'0' && field[i][j]-'0'<=N){factory[field[i][j]-'0']=P(i,j);}
			if(field[i][j]=='S'){factory[0]=P(i,j);}
		}
	}
	for(i=0;i<N;i++){
		minute+=solve(i);//i??????????????????????£?????????¢?´¢
	}
	cout<<minute<<endl;
	return 0;
}

Measured memory_bytes: 6096
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	map<int,int> cnt;
	rep(i,N){
		int t; cin>>t;
		cnt[t] ++;
	}
	int ans = cnt.size();
	int ad = 0;
	for(auto x: cnt){
		if(x.second >= 2)ad += x.second-1;
	}
	ans -= ad%2;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll h,w,d;
    cin >>h>>w>>d;
    vector<P>p(h*w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ll a;cin >>a;
            a--;
            p[a]=make_pair(i,j);
        }
    }
    vector<ll>a(h*w,0);
    for (int i = 0; i < h * w; ++i) {
        if(i<d)a[i]=0;
        else {
            a[i]=a[i-d]+abs(p[i].first-p[i-d].first)+abs(p[i].second-p[i-d].second);
        }
    }
    ll q;cin >>q;
    for (int i = 0; i < q; ++i) {
        ll l,r;cin >>l>>r;
        l--,r--;
        cout <<a[r]-a[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int n, c, k; cin >> n >> c >> k;
    int t[100100];
    rep(i, n) {
        cin >> t[i];
    }
    sort(t, t + n);
    int ans = 0;
    int i = 0, j;
    while(i < n) {
        j = upper_bound(t, t + n, t[i] + k) - t;
        j = min(i + c, j);
        ans ++;
        i = j;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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


int main(void)
{
    int *data;
    int n, i, j;
    int swapped;
    int temp;

    scanf("%d", &n);
    data = malloc(n * sizeof(int));

    swapped = 0;
    for (i = 0; i < n; i++) scanf("%d", &data[i]);
    for (i = 0; i < n; i++){
        for (j = n - 1; j > i; j--){
            if (data[j] < data[j - 1]){
                temp = data[j];
                data[j] = data[j - 1];
                data[j - 1] = temp;
                swapped++;
            }
        }
    }

    for (i = 0; i < n - 1; i++) printf("%d ", data[i]);
    printf("%d\n", data[i]);

    printf("%d\n", swapped);
    free(data);
    return (0);
}


Measured memory_bytes: 2100
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(a + b >= k){
        cout << min(a, k) << endl;
    } else {
        cout << a - (k - (a + b)) << endl;
    }
}


Measured memory_bytes: 3636
N = int(input())
A = [list(map(int, input().split())) for _ in (0, 1)]

k = 0
s1 = 0
s2 = sum(A[1])
for i in range(N):
	s1 += A[0][i]
	k = max(k, s1 + s2)
	s2 -= A[1][i]

print(k)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
namespace Fast_Read {
	inline void read(int &res) {
		res = 0;int tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
	inline void read(long long &res) {
		res = 0;long long tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
}
using namespace Fast_Read;
const int maxn = 1e5+10;
int R[maxn],t[maxn],y[maxn],a[maxn],b[maxn],c[maxn];
int L,K,q;
int main() {
	a[0] = 0;
	b[0] = 0x3f3f3f3f;
	c[0] = -0x3f3f3f3f;
	read(L);read(K);
	for (register int i = 1;i <= K;++i)read(R[i]);
	a[1] = -R[1];
	b[1] = 0x3f3f3f3f;
	c[1] = 0;
	for (register int i = 2;i <= K;++i) {
		int tmp = R[i]-R[i-1];
		if (i&1) {
			a[i] = a[i-1]-tmp;
			b[i] = b[i-1]-tmp;
			c[i] = max(c[i-1]-tmp,0);
		}
		else {
			a[i] = a[i-1]+tmp;
			b[i] = min(max(b[i-1],c[i-1])+tmp,L);
			c[i] = min(c[i-1]+tmp,L);
		}
	}
	read(q);
	for (register int i = 1;i <= q;++i) {
		read(t[i]);read(y[i]);
		int l = 0,r = K;
		while (l <= r) {
			int mid = (l+r)>>1;
			if (t[i] >= R[mid])l = mid+1;
			else r = mid-1;
		}
		l--;
		t[i] -= R[l];
		y[i] = max(min(y[i]+a[l],b[l]),c[l]);
		if (l&1)y[i] = min(y[i]+t[i],L);
		else y[i] = max(y[i]-t[i],0);
		printf("%d\n",y[i]);
	}
	return 0;
}

Measured memory_bytes: 3584
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int p = 100000;
		for(int i=0;i<n;i++) {
			p = (int)(p * 1.05);
//			System.out.println(p);
			if(p%1000 > 0) p -= p%1000 - 1000;
//			System.out.println(p);
		}
		System.out.println(p);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 11000