akhauriyash/Code-Regression huggingface dataset:
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
   IOS();
  
   ll a,b,c;
   char s,t;
   cin>>s;
   s++;
   cout<<s<<'\n';

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#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 FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................
bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}


int main()
{
    fast
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

n,m = list(map(int, input().split()))
a = []
b = []
for _ in range(m):
    aa, bb = list(map(int, input().split()))
    a.append(aa-1)
    b.append(bb-1)

a = a[::-1]
b = b[::-1]

ans = int(n * (n - 1) /2)
ans_rec = [0] * m
ans_rec[-1] = ans

p = [-1 for i in range(n)]
size = [1 for i in range(n)]

def find(x):
#     print(x, p[x])
    px = p[x]
    if px <0:
        return x
    else:
        pxx = find(px)
        p[x] = pxx
        return pxx

for k in range(m-1):
    pa = find(a[k])
    pb = find(b[k])
    if pa == pb:
        pass
    else:
        ans -= size[pa] * size[pb]
        size[pa] += size[pb]
        p[pb] = pa
    ans_rec[- k - 2] = ans
for aa in ans_rec:
    print(aa)

Measured memory_bytes: 32464
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    for(int i=0;i<MAX;i++){
        if(!is_prime[i]){
            sumprime[i]=sumprime[i-1]+i;
        }else{
            sumprime[i]=sumprime[i-1];
        }
    }
}
*/
/*
void lcs(char s1[],char s2[]){
    int n=strlen(s1);
    int m=strlen(s2);
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int sum=0;
            if(s1[i-1]==s2[j-1]){
                sum=1+dp[i-1][j-1];
            }
            else{
                sum=max(dp[i-1][j],dp[i][j-1]);
            }
            dp[i][j]=sum;
        }
    }
    
    int index=dp[n][m];
    //cout<<index<<endl;
    char ans[index+1];
    ans[index]='\0';
    index--;
    int x=n;
    int y=m;
    while(x>0 and y>0){
        if(dp[x-1][y]==dp[x][y-1] and dp[x-1][y]!=dp[x][y]){
            ans[index]=s1[x-1];
            index--;
            x--;
            y--;
        }else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }else{
            y--;
        }

    }
    //reverse(ans.begin(),ans.end());

    cout<<ans;
    return;
}
*/
vector<int> adj[100005];
int dp[100005];
bool vis[100005];

void dfs(int node){
    vis[node]=1;
    dp[node]=0;
    for(auto x:adj[node]){
        if(!vis[x]){
            dfs(x);
        }
        dp[node]=max(dp[node],dp[x]+1);
    }
}

using namespace std;
int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            adj[x].pb(y);
        }
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                dfs(i);
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            ans=max(ans,dp[i]);
        }
        cout<<ans<<'\n';

    }
    
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 12580
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll K, X;
	cin >> K >> X;
	for (int i = X - K + 1; i < K + X; i++) {
		if (i != K + X - 1) {
			cout << i << " ";
		}
		else {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
N = int(input())

moneylist = [1]

money = 6

while money < 100000:
    moneylist.append(money)
    money = money*6

money = 9    

while money < 100000:
    moneylist.append(money)
    money = money*9
moneylist.sort()

dp = [10**6]*(N+1)
dp[0] = 0

for i in range(1,N+1): #お金
    for j in moneylist: #使えるお金
        if j <= i:
            dp[i] = min(dp[i],dp[i-j] + 1)
        
print(dp[-1])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int main(){
	//	fri(".in");
	//	fro(".out");
	string st;
	cin>>st;
	if(st=="MON"){
		cout<<6<<endl;
	}
	if(st=="TUE"){
		cout<<5<<endl;
	}
	if(st=="WED"){
		cout<<4<<endl;
	}
	if(st=="THU"){
		cout<<3<<endl;
	}
	if(st=="FRI"){
		cout<<2<<endl;
	}
	if(st=="SAT"){
		cout<<1<<endl;
	}
	if(st=="SUN"){
		cout<<7<<endl;
	}

	return 0;
}



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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  int suml=0;
  int sumh=0;
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    if(x<X)suml+=1;
    else sumh+=1;
  }
  cout << min(suml,sumh);
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

void a_rgb_cards(void) {
	int r, g, b;
	cin >> r >> g >> b;

	int sum = 100 * r + g * 10 + b;
	if ((sum & 0x3) == 0x0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  
  if(S.size() <= K){
    cout << S << endl;
  }
  
  if(S.size() > K){
    std::string str = S;
    cin >> S;
    std::string substr = str.substr(0, K);
    std::cout << substr << "..." << std::endl;
  }
    
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    double r;   cin>>r;
    cout<<fixed;
    cout<<setprecision(5)<<M_PI*r*r<<" "<<setprecision(6)<<M_PI*2*r<<endl;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

ll mod = 1e9+7; 
 ll dp[2000][2000];


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

  ll n,m,i,j;

  cin>>n>>m;
  string s[n+1];

  for(i=0;i<n;i++)
  {
    cin>>s[i];
  }

  dp[1][1]=1;

  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      if(i == 1 && j == 1)continue;
      if(s[i-1][j-1] == '.')
      {
        dp[i][j] = dp[i-1][j]+dp[i][j-1];
        dp[i][j]%=mod;
      }
    }
  }


  cout<<dp[n][m]<<"\n";

  return 0;
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define plli pair<lli,lli>
#define pslli pair<string,lli>
#define pclli pair<char,lli>
const lli N=4e5+5;


int main()
{


    fast;
    lli n,a;
    cin>>n>>a;
    if(n%a)
    {
        cout<<n/a+1;
    }
    else
        cout<<n/a;





    return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	private void doit() {
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			int [] data = new int[n];
			int sum = 0;
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
				sum += data[i];
			}
			Arrays.sort(data);
			for(int i = n-m; i >= 0; i-= m){
				sum -= data[i];
			}
			System.out.println(sum);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 54444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s;cin>>s;
	if(s == "ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
const int S = 2020;
int comb[S+10][S+10];
signed main() {
    int N, K; cin >> N >> K;
    for(int i=0; i<S; i++) {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++) {
            (comb[i][j] += comb[i-1][j-1] + comb[i-1][j]) %= MOD;
        }
    }

    cout << comb[K][N] << endl;
    return 0;
}



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

int N;
LL ans1, ans2, A[101010];

int main(){
    scanf("%d", &N);
    for (int i=1; i<=N; i++) scanf("%lld", &A[i]);
    LL Sum = 0;
    for (int i=1; i<=N; i++){
        Sum += A[i];
        if (i & 1){
            if (Sum <= 0) ans1 += 1 - Sum, Sum = 1;
        }
        else if (Sum >= 0){
            ans1 += Sum + 1;
            Sum = -1;
        }
    }
    Sum = 0;
    for (int i=1; i<=N; i++){
        Sum += A[i];
        if (i & 1){
            if (Sum >= 0) ans2 += Sum + 1, Sum = -1;
        }
        else if (Sum <= 0){
            ans2 += 1 - Sum;
            Sum = 1;
        }
    }
    printf("%lld\n", min(ans1, ans2));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <utility>
#include <map>
#define N 1e5+5;
typedef long long ll;
using namespace std;

int main() {
	int k,a,b,d;
	cin >> k >> a >> b;
	for (int i=1; d<=b; i++) {
		d=k*i;
		if (d>=a && d<=b) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define pb push_back
#define lim 100001

using namespace std;
int main()
{ll n,m;
	cin>>n>>m;
	m-=(2*n);
	if(m<0 || m%2)
		{cout<<"No"<<endl;
		return 0;}
		m/=2;
		if(n-m<0)
			{cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;



}

Measured memory_bytes: 3604
import sys
import heapq
N, M = map(int, input().split())

G = [[] for i in range(3*N)]
for i in range(M):
    u, v = map(int, input().split())
    G[u-1].append([v-1 + N, 1])
    G[u-1 + N].append([v-1 + 2*N, 1])
    G[u-1 + 2*N].append([v-1, 1])

S, T = map(int, input().split())

INF = 10**10
d = [INF for i in range(3*N)]

que = []
d[S-1] = 0
heapq.heappush(que, [0, S-1])

while not(len(que) == 0):
    q = heapq.heappop(que)
    ver = q[1]
    dis = q[0]
    
    if d[ver] < dis:
        continue

    for i in range(len(G[ver])):
        e = G[ver][i]
        if d[e[0]] > d[ver] + e[1]:
            d[e[0]] = d[ver] + e[1]
            heapq.heappush(que, [d[e[0]], e[0]])

if d[T-1] == INF:
    print(-1)
else:
    print(d[T-1]//3)

Measured memory_bytes: 88496
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, W;
	cin >> N >> W;
	vector<ll> w(N);
	vector<ll> v(N);
	REP(i, N) cin >> w[i] >> v[i];
	vector<vector<ll>> dp(N, vector<ll>(W + 1, -1));
	dp[0][0] = 0;
	dp[0][w[0]] = v[0];
	FOR(i, 1, N) REP(j, W + 1) {
		dp[i][j] = dp[i - 1][j];
		if(j - w[i] >= 0 && dp[i - 1][j - w[i]] != -1) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
	}
	ll ans = 0;
	REP(i, W + 1) ans = max(ans, dp[N - 1][i]);
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 79488
import java.util.Scanner;

class Main {
    static Scanner sc;
    static int mod = (int)Math.pow(10, 9) + 7;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] grid = new boolean[h][w];
        for(int i = 0; i < h; i++) {
            String line = sc.next();
            for(int j = 0; j < w; j++) {
                if(line.charAt(j) == '#') grid[i][j] = true;
            }
        }
        int[][] dp = new int[h][w];
        dp[0][0] = 1;
        for(int i = 1; i < w; i++) {
            if(grid[0][i]) dp[0][i] = 0;
            else dp[0][i] = dp[0][i - 1];
        }
        for(int i = 1; i < h; i++) {
            if(grid[i][0]) dp[i][0] = 0;
            else dp[i][0] = dp[i - 1][0];
        }
        for(int i = 1; i < h; i++) {
            for(int j = 1; j < w; j++) {
                if(grid[i][j]) dp[i][j] = 0;
                else dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
            }
        }
        print(dp[h - 1][w - 1]);
    }
}


Measured memory_bytes: 34200
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[105][100005];
ll m_v(int n, int W, int weight[],int value[]){
    if(n==0 || W<=0) return 0;
    if(dp[n][W]!=-1) return dp[n][W];
    ll op1=m_v(n-1,W,weight,value);
    
    ll op2=weight[n-1]<=W ? m_v(n-1,W-weight[n-1],weight,value) + value[n-1]: INT_MIN;
    
    return dp[n][W]=max(op1,op2);
    
}

int main(){
    int n,W; cin>>n>>W;
    memset(dp,-1,sizeof(dp));
    int weight[n],value[n];
    for(int i=0;i<n;i++) cin>>weight[i]>>value[i];
    cout<<m_v(n,W,weight,value);
}

Measured memory_bytes: 85680
from math import sqrt

def main():

  N, D = map(int, input().split())
  P = [list(map(int, input().split())) for i in range(N)]
  ans = 0
  for i in range(N):
    if sqrt(P[i][0]**2 + P[i][1]**2) <= D:
      ans += 1
  print(ans)
main()

Measured memory_bytes: 107188
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  /// freopen("input.txt","r",stdin);
  /// freopen("output.txt","w",stdout);
	lli t=1;
    //cin>>t;
	while(t--)
	{
        lli n,i,j,k,x,y;
        cin>>n;
        lli v[n],c[n];
        for(i=0;i<n;i++)
        {
            cin>>v[i];
        }
        lli ans=0;
        for(i=0;i<n;i++)
        {
            cin>>c[i];
            if(v[i]-c[i]>0)
            ans+=v[i]-c[i];
        }
        cout<<ans<<endl;
    }
}
/*
1
8 2
1 0 1 0 0 1 0 0
*/


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

#define PY "Yes\n"    // printf(PY);
#define PN "No\n"     // printf(PN);


int main()
{
    int h, n, i, sum=0;
    scanf("%d%d", &h, &n);
    int arr[n+5];
    for(i=1; i<=n; i++)
    {
        scanf("%d", &arr[i]);
        sum = sum + arr[i];
    }


    if(sum>=h)
        printf(PY);
    else
        printf(PN);

    return 0;
}


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

int main(){
	double r;
	cin>>r;
	double a = 3.14159265358979323846264338328*r*r;
	double b = 2*3.14159265358979323846264338328*r;
	
	printf("%.6f %.6f\n", a, b);
	
	return 0;
	
}


Measured memory_bytes: 3292
import sys

N = int(sys.stdin.read().strip())
total = 0
for v in range(6):
  if v % 2 != 0:
    continue
  low = 10 ** v
  high = 10 ** (v+1)
  if N < low:
    break
  if N >= high:
    total += high - low
  else:
    total += N - low + 1
    break
print(total)


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



int main() {
	int n;
	cin >> n; 
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s.substr(i, 3) == "ABC") cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3600
def slove():
    import sys
    input = sys.stdin.readline
    a = list(map(str, str(input().rstrip('\n')).split()))
    t = int("".join(a))
    print("Yes" if t ** 0.5 == int(t ** 0.5) else "No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast	
//cout << setprecision(15) << fixed;

cin >> n;
vll a(n);
  fr(i,0,n){
    cin >> a.at(i);
  }
  ll ans=0;
  fr(i,0,n){
     ans=ans^a.at(i);
  }
  fr(i,0,n){
    ll p=ans;
    p=ans^a.at(i);
    cout << p << " ";
  }
 eNd();
  return 0;
 
}

Measured memory_bytes: 4728
import sys

input = sys.stdin.readline
P = 10**9 + 7


def main():
    N, M = map(int, input().split())

    if abs(N - M) > 1:
        ans = 0
    else:
        n = 1
        for i in range(1, N + 1):
            n = (n * i) % P
        m = 1
        for i in range(1, M + 1):
            m = (m * i) % P

        ans = (n * m) % P
        if N == M:
            ans = (2 * ans) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n=int(input())
b=input().split()
s=b[:]
for i in range(n):
    for j in range(n-1,i,-1):
        if b[j][1]<b[j-1][1]:b[j],b[j-1]=b[j-1],b[j]
    m=i
    for j in range(i,n):
        if s[m][1]>s[j][1]:m=j
    s[m],s[i]=s[i],s[m]
print(*b)
print('Stable')
print(*s)
print(['Not s','S'][b==s]+'table')

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

using namespace std;

//#define FILE_IO

typedef long long LL;

const LL INF = (1LL << 60);

int N;
LL v[100005];
bool f[100005][3];
LL mem[100005][3];

int gint()
{
    char ch = getchar();
    int sgn = 1;
    while(ch < '0' || '9' < ch)
    {
        if(ch == '-')   sgn = -1;
        ch = getchar();
    }
    int x = 0;
    while('0' <= ch && ch <= '9')
    {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= sgn;
    return x;
}

LL solve(int pos, int grad)
{
    if(pos > N) return 0;
    if(grad < 0 || grad > 2)  return (-INF);
    if(f[pos][grad])    return  mem[pos][grad];

    f[pos][grad] = 1;
    LL val = v[pos];
    if(grad & 1)    val *= -1;

    LL slv1 = solve(pos + 1, grad - 2);
    LL slv2 = solve(pos + 1, grad - 1);
    LL slv3 = solve(pos + 1, grad);
    LL slv4 = solve(pos + 1, grad + 1);
    if(v[pos] > 0)  slv4 = -INF;

    LL ans = val + max( max(slv1, slv2), max(slv3, slv4) );
    mem[pos][grad] = ans;
    return ans;
}

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

    N = gint();
    for(int i = 1; i <= N; i++)
        v[i] = gint();

    LL ans = solve(1, 0);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 13056
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;


int main() {
	ifstream fin("Text.txt");
	int i, j, k;
	ll a, b, c, e, f, n, t, m, r, d, q, x, y,tw,ts;
	
	cin >> a >> b >> c >> d >> e >> f;
	VEC water(f+1), sugar(f+1);
	water[100 * a] = 1;
	water[100 * b] = 1;
	sugar[c] = 1;
	sugar[d] = 1;
	a *= 100;
	b *= 100;
	forc(i, 1, f) {
		if (water[i]) {
			if (i + a <= f)
				water[i + a] = 1;
			if (i + b <= f)
				water[i + b] = 1;
		}
		if (sugar[i]) {
			if (i + c <= f)
				sugar[i + c] = 1;
			if (i + d <= f)
				sugar[i + d] = 1;
		}
	}
	water[0] = 1;
	sugar[0] = 1;
	tw = a;
	ts = 0;
	forc(i, 1, f) {
		forc(j, 1, f) {
			if (water[i] && sugar[j] &&
				i + j <= f &&
				100 * j <= e*i &&
				j * tw >= ts*i ) {
				ts = j;
				tw = i;
			}
		}
	}
	cout << ts + tw << " " << ts << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	int ab = a < b;
	int bc = b < c;
	int ca = c < a;

	int cost;
	
	if (ab) {
		if (bc) { // abc
			cost = (c - b) + (b - a);
		}
		else if (ca) { // cab
			cost = (b - a) + (a - c);
		}
		else { // acb
			cost = (b - c) + (c - a);
		}
	} else {
		if (!bc) { // cba
			cost = (a - b) + (b - c);
		} else if (ca) { // bca
			cost = (a - c) + (c - b);
		} else { // bac
			cost = (c - a) + (a - b);
		}
	}
	
	printf("%d\n", cost);

}

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

int main(){
  string S ; 
  cin >> S ; 
  int T = 0 ; 
  int max = 0 ; 
  int N ; 
  N = S.size() ; 
  
  for(int i = 0 ; i < N ; i++){
    if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G'|| S.at(i) == 'T' ){
      T++ ; 
    }
    else{
      if(T >= max){
        max = T ; 
      }
      T = 0 ; 
    }
  }
  
  if(max <= T){
    cout << T << endl ; 
    return 0 ; 
  }
  
  cout << max << endl; 

}



Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>

int main(int argc,char **argv){
    char script[101];
    int i,count=0;

    scanf("%s",script);
    int n = strlen(script);
    for(i=0;i<n;i++){
        if(script[i] != script[n-1-i])count++;
    }
    printf("%d\n",count/2);
    return 0;
}

Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, Q;
    cin >> n >> Q;
    vector<queue<int>> q(n);
    while (Q--) {
        int com, t;
        cin >> com >> t;
        if (com == 0) {
            int x;
            cin >> x;
            q[t].push(x);
        } else if (com == 1) {
            if (!q[t].empty()) cout << q[t].front() << endl;
        } else{
            if (!q[t].empty()) q[t].pop();
        }
    }
}



Measured memory_bytes: 4264
#include<iostream>
using namespace std;
int a[1001];
int main()
{
    int n,m,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int index1,index2;
    index1=sum/n;
    index2=sum/n+1;//对称点不一定为整数所以需要将两个数都求出来然后比较
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        sum1+=(index1-a[i])*(index1-a[i]);
        sum2+=(index2-a[i])*(index2-a[i]);
    }
    cout<<min(sum1,sum2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import division, print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの


def main():
    value = [0] * 1000
    weight = [0] * 1000
    casenum = 1
    while True:
        W = int(input())
        if(W == 0):
            return
        N = int(input())
        dp = [[0 for x in range(W+1)] for y in range(N+1)]
        for x in range(0, N):
            value[x], weight[x] = map(int, input().split(','))
        for i in range(0, N):
            for w in range(0, W+1):
                if w - weight[i] >= 0:
                    use = dp[i][w - weight[i]] + value[i]
                else:
                    use = 0
                unuse = dp[i][w]
                dp[i+1][w] = max(use, unuse)
        print("Case " + str(casenum) + ":")
        for w in range(W+1):
            if(dp[N][w] == dp[N][W]):
                print(str(dp[N][w]) + "\n" + str(w))
                break
        casenum += 1
main()

Measured memory_bytes: 15368
incr::Int -> Int -> Int
incr now k = if now > k then now+k else now*2

solver::Int-> Int -> Int
solver 0 k = 1
solver n k = incr (solver (n-1) k) k

main::IO()
main=do
  nc<-getLine
  kc<-getLine
  let n = read nc
  let k = read kc
  print (solver n k)

Measured memory_bytes: 508
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)
ans=a[1]
for i in range(n-1):
    if min(a[0]-a[i+1],a[i+1])>min(a[0]-ans,ans):
        ans=a[i+1]
    # print(ans)
print(a[0],ans)

Measured memory_bytes: 89880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
const ll one = 1;

int main(){
    char s;
    cin >> s;
    printf("%c\n", s+1);

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
	map<char,int> m;
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++)
	{
		m[str[i]]++;//统计每个方向走的步数
	}
	if(((m['N']+m['S']!=0)&&(m['N']*m['S']==0))||((m['E']+m['W']!=0)&&(m['E']*m['W']==0)))//只有其中一个
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 3e3+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

LL dp[nmax][nmax];

int main()
{
    optimizeIO();

    int n;
    cin>>n;

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

    /// can't do this as we need to start from segment of length 1 in iterative dp
//    for(int l=0; l<n; l++)
//        for(int r=n-1; r>=l; r--)

    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l==r) dp[l][r] = v[l];
            else dp[l][r] = max(v[l]-dp[l+1][r] , v[r]-dp[l][r-1]);
        }
    }

    cout<<dp[0][n-1]<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 49416
#!/usr/bin/env python3
import sys

def get_div_cnt(H):
    c = 1 if H[0] > 0 else 0

    for i in range(1,len(H)):
        if H[i-1] == 0 and H[i] > 0:
            c += 1

    return c

def solve(N: int, H: "List[int]"):
    R = 0
    while sum(H) > 0:
        R += get_div_cnt(H)
        for i in range(len(H)):
            if H[i] > 0:
                H[i] -= 1

    print(R)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    Rep (i, 60) {
        ll cnt = 0;
        Rep (j, N) {
            if ((A[j] >> i) & 1) {
                cnt++;
            }
        }

        if (cnt % 2 == 1) {
            // cout << "i=" << i << "\n";
            ans += (1LL << i);
            Rep (j, N) {
                A[j] &= ~(1LL << i);
            }
        }
    }

    // printvec(A);

    vec basis;
    for (ll e : A) {
        for (ll b : basis) {
            chmin(e, e ^ b);
        }
        if (e) {
            basis.push_back(e);
        }
    }
    
    sort(basis.begin(), basis.end());

    ll n = basis.size();
    Rep (i, n) {
        Rep (j, n) {
            if (i == j) continue;
            chmin(basis[j], basis[j] ^ basis[i]);
        }
    }

    // printvec(basis);

    ll tmp = 0;
    for (ll e : basis) {
        tmp = tmp ^ e;
    }

    ans += 2 * tmp;
    cout << ans << "\n";

    // for (ll i = n-1; i >= 0; i--) {
    //     ans += 2 * basis[i];
    //     for (ll digit = 59; digit >= 0; digit--) {
    //         if (basis[i] >> digit & 1) {
    //             for (ll j = i-1; j >= 0; j--) {
    //                 if (basis[j] >> digit & 1) basis[j] = 0;
    //             }
    //         }
    //     }
    // }

    // cout << ans << "\n";

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

int main(){
    string S, T;
    cin >> S >> T;
    
    if(T.length() > S.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    int L = T.length();
    
    string ans = "";
    for(int i = 0; i < 50; ++i){
        ans += 'z';
    }
    string unti = ans;
    
    for(int i = S.length() - L; i >= 0; --i){
        bool flag = true;
        for(int j = 0; j < L; ++j){
//            cout << S[i + j] << " ";
            if(S[i + j] == '?'){
                continue;
            } else if(S[i + j] == T[j]){
                continue;
            } else {
                flag = false;
                break;
            }
        }
        string tmp = "";
        if(flag){
            for(int j = 0; j < S.length(); ++j){
                if(j < i || (j >= i + L)){
                    if(S[j] == '?'){
                        tmp += 'a';
                    } else {
                        tmp += S[j];
                    }
                } else {
                    tmp += T[j - i];
                }
            }
            ans = min(ans, tmp);
        }
    }
    if(ans < unti){
        cout << ans << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
using namespace std;
char S[100001];
char ans[600000];
#define OFFSET (200000)

int main()
{
  int Q;
  scanf("%s", S);
  cin >> Q;
  int len = strlen(S);
  memcpy(&ans[OFFSET], S, len);

  int left = OFFSET - 1;
  int right = OFFSET + len;

  bool rev = false;
  for (int i = 0; i < Q; i++) {
    int T, F;
    char c;
    cin >> T;
    if (T==1) {
      rev = !rev;
    } else {
      cin >> F >> c;
      if (F==1) {
        if (rev) {
          ans[right++] = c;
        } else {
          ans[left--] = c;
        }
      } else {
        if (rev) {
          ans[left--] = c;
        } else {
          ans[right++] = c;
        }
      }
    }
  }
  if (rev) {
    for (int i = right-1; i > left; i--) {
      putchar(ans[i]);
    }
  } else {
    for (int i = left+1; i < right; i++) {
      putchar(ans[i]);
    }
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 896
n,a,b = map(int,input().split())
s = input()
m = 0
b_rank = 0
for i in s:
    if i=="a" and m<a+b:
        m+=1
        print("Yes")
    elif i=="b" and m<a+b and b_rank+1<=b:
        b_rank+=1
        m+=1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
using namespace std;

const long long mod=1000000007;
const long long inf=mod*mod;


int w[110];
int val[110];
long long dp[2][1100000];


int main(){

    long long int n,wt;
    cin>>n;
    cin>>wt;
    for(int i=0;i<n;i++){
    cin>>w[i];
    cin>>val[i];
}
    for(int j=1;j<1100000;j++) dp[0][j]=inf;
    for(int i=1;i<=n;i++){
        int t=i%2;
        for(int j=0;j<1100000;j++) dp[t][j]=inf;
        for(int j=0;j<1100000;j++){
            dp[t][j]=min(dp[t][j],dp[!t][j]);
            if(j-val[i-1]>=0) dp[t][j]=min(dp[t][j],dp[!t][j-val[i-1]]+w[i-1]);
        }
    }
    int ans=0;
    for(int i=0;i<1100000;i++) if(dp[n%2][i]<=wt)ans=i ;
    cout<<ans;
return 0;
}


Measured memory_bytes: 17408
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;



signed main()
{
	int N, K;
	int l[50];

	cin >> N >> K;
	REP(i, N) cin >> l[i];
	ARY_SORT(l, N);

	int ans = 0;
	REP(i, K)
	{
		ans += l[N - i - 1];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
X,Y=map(int,input().split())
mod=10**9+7
MAX=X+Y+1

fac=[1,1]
inv_t=[0,1]
finv=[1,1]
for i in range(2,MAX):
    fac.append(fac[-1]*i%mod)
    inv_t += [inv_t[mod % i] * (mod - mod // i) % mod]
    finv.append(finv[i-1]*inv_t[i]%mod)

x=2*X-Y
y=2*Y-X

if x%3!=0 or y%3!=0 or x*y<0:
    print(0)
else:
    x=x//3
    y=y//3
    n=x+y
    r=min(x,y)
    print((fac[n]*finv[r]*finv[n-r])%mod)

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


int main(void) {
    int n;
    cin >> n;

    string s;
    cin >> s;

    int r =0;
    int b =0;

    for(int i =0; i < s.size(); ++i){
        if(s[i]=='R') {
            r++;
        } else {
            b++;
        }
    }

    if(r>b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = CinTAr();
            int a = t[2];
            for(int i = 2001;i < 2011; i++)
            {
                a = t[0] * a - t[1];
                Cout(a);
            }
            Cin();
        }



        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        static int[] yakusuu(int n)
        {
            if (n == 1) { return new int[] { 1 }; }
            HashSet<int> res = new HashSet<int>();
            for (int i = 1; i < Math.Ceiling(n / 2.0); i++)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    res.Add(n / i);
                }
            }
            return res.ToArray();
        }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int s[500],l[500],p[500];
int w[500];
int dp[500];

int main() {
  int n;
  while(cin >> n) {
    REP(i,n) {
      cin >> s[i] >> l[i] >> p[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    REP(i,n) {
      for (int j=s[i]; j<=l[i]; ++j) {
        REP(k,400-j) {
          if (dp[k] == -1) continue;
          chmax(dp[j+k], dp[k] + p[i]);
        }
      }
    }
//    REP(i,10) cout << dp[i] << " " ; cout << endl;
    int m; cin >> m;
    vector<int> ans;
    bool flag = 0;
    REP(i,m) {
      int w; cin >> w;
      if (dp[w] == -1) flag = 1;
      ans.push_back(dp[w]);
    }
    if (flag) cout << -1 << endl;
    else {
      FOR(it, ans) cout << *it << endl;
    }
  }
}

Measured memory_bytes: 1232