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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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 = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  string s; cin>>s;
  reverse(all(s));
  bool ok=true;
  vll ans;
  ll pos=0;
  while(true){
    bool flg=false;
    rreps(i,m){
      if(pos+i<=n && s[pos+i]=='0'){
        ans.push_back(i);
        pos+=i;
        flg=true;
        break;
      }
    }
    if(!flg){
      ok=false;
      break;
    }
    if(pos==n) break;
  }
  
  if(!ok){
    cout<<-1<<endl;
    return 0;
  }
  
  reverse(all(ans));
  rep(i,ans.size()){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1480
#include <iostream>
#include <string>
#include <vector>
//#include <algorithm>

using namespace std;

int main() {
    string n;
    vector<int> s;
    cin >> n;
    
    for(int i = 0;i < n.size(); ++i) {
        //cout << i << "\n";
        if(!s.empty() && n[i] == 'B') {
            s.pop_back();
        } else if(n[i] == '0') {
            s.push_back(0);
        } else if(n[i] == '1') {
            s.push_back(1);
        }
    }

    for(int i = 0;i < s.size(); ++i) {
        cout << s.at(i);
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long a = scanner.nextLong(), b = scanner.nextLong(), c = scanner.nextLong(), d = scanner.nextLong();
			System.out.println(max(a * c, a * d, b * c, b * d));
		}
	}

	/**
	 * 配列の最大値を計算する
	 * 
	 * @param a 配列
	 * @return 配列の最大値
	 */
	private static long max(long... a) {
		return Arrays.stream(a).max().getAsLong();
	}
}


Measured memory_bytes: 35876
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] F =new int[N+1];
        HashMap<Integer,Integer> dic = new HashMap<>();
        for(int i=0;i<=1024;i++){
            int j=i;
            int cnt = 0;
            while(j>0){
                cnt += j&1;
                j = j>>1;
            }
            dic.put(i,cnt);
        }
        for(int i=1;i<=N;i++){
            for(int j=0; j<9; j++){
                int cur = sc.nextInt();
                F[i] += cur;
                F[i] *= 2;
            }
            F[i] += sc.nextInt();
        }
        int[][] P = new int[N+1][11];
        for(int i=1;i<=N;i++){
            for(int j=0; j<= 10; j++){
                P[i][j] = sc.nextInt();
            }
        }
        long ans = Long.MIN_VALUE;
        for(int i=1;i<1024;i++){
            long cur = 0;
            for(int j=1;j<=N;j++){
                int together = i&F[j];
                int temp = P[j][dic.get(together)];
                cur += temp;
            }
            ans = Math.max(ans,cur);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28120
from scipy.sparse import*
_,*s=open(0)
M=999
*g,=eval('[0]*M,'*M)
i=0
for t in s:
 j=0
 for u in t:k=i*20+j;g[k][k+1]=u>'#'<t[j+1];g[k][k+20]=u>'#'<(s+['#'*M])[i+1][j];j+=1
 i+=1
a=csgraph.johnson(csr_matrix(g),0)
print(int(max(a[a<M])))

Measured memory_bytes: 31908
#include <stdio.h>
 
int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;
 
 
  while(1){
    i=0;
    while(1){
       
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
    break;
      }
       
      i++;
    }
    
    if ( i == 1 && ch[0] == '-' ) break;
 
    //  printf("%d",i);
     
    scanf("%d",&m);
     
    for(j=0;j<m;j++){
      scanf("%d", &h );
       
      for(k=0;k<i-h;k++) {
    a[k] = ch[h+k];
    //    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
    a[i-h+k] = ch[k];
    //   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
    ch[k] = a[k];
    // printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
   
   
  return 0;
   
}


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

NO = "IMPOSSIBLE"  # type: str

def solve(A: int, B: int):
    if(abs((A-B)%2) == 0):
        print(min(A,B)+int(abs(A-B)/2))
    else:
        print(NO)
    return


# 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100005


int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   string s,t;cin>>s>>t;
   int n=s.size(),m=t.size();
   int ans=INT_MAX;
   for(int i=0;i<=n-m;i++){
      int cnt=0,idx=i;
      for(int j=0;j<m;j++){
         cnt+=(s[idx++]!=t[j]);
      }
      ans=min(ans,cnt);
   }
   cout<<ans<<"\n";
   return 0;
}



Measured memory_bytes: 3652
#include<iostream>

int main(){
	int a[10],i,n,p;

	for(i=0;i<10;i++){
		std::cin >> a[i];
	}for(i=0;i<9;i++){
		for(p=i+1;p<10;p++){
			if(a[i]<a[p]){
				n=a[i];
				a[i]=a[p];
				a[p]=n;
				}
			}
		}
	for(i=0;i<3;i++){
		std::cout<<a[i]<<std::endl;
		}
	return 0;
	}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
  long long H,k=1,l=1;
  scanf("%lld",&H);
  while(1)
  {
    if(H>1)
    {
      k=k*2;
      H=H/2;
      l=l+k;
    }
    else
      break;
  }
  printf("%lld",l);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<b; i++)
#define REP(i, n)    for(int i=0; i<(n); i++)
#define fst first
#define pb push_back
#define mp make_pair
#define ALL(obj) (obj).begin(), (obj).end()
using ul = unsigned long;
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int absInt(int a, int b){
  if(a>b) return a-b;
  return b-a;
}

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

  int a[5], k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

  if(a[4]-a[0]>k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int MOD=1e9 + 7;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    ll h,n;
    cin>>h>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        sum+=x;
    }
    if(sum>=h)
        cout<<"Yes\n";
    else 
        cout<<"No\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


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

int main()
{
        int x,y;
        int z[15] = {0,1,2,1,3,1,3,1,1,3,1,3,1};
        cin>>x>>y;
        if(z[x]==z[y])cout<<"Yes\n";
        else cout<<"No\n";
        return 0;
}

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

char toC(int n)
{
    for (char c = 'A'; c <= 'Z'; c++)
    {
        if (c - 'A' == n)
        {
            return c;
        }
    }
    return 'a';
}

int main()
{
    vector<int> ansS, ansN;
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            break;
        }
        vector<int> num(30, 0);
        vector<char> c(n);
        for (int i = 0; i < n; i++)
        {
            cin >> c[i];
        }
        for (int i = 0; i < n; i++)
        {
            num[c[i] - 'A']++;
            int first = 0, second = 0;
            int Sub = 0;
            for (int j = 0; j < 30; j++)
            {
                if (first < num[j])
                {
                    second = first;
                    first = num[j];
                    Sub = j;
                }
                else if (first >= num[j] && num[j] > second)
                {
                    second = num[j];
                }
            }
            if (first > second + n - i - 1)
            {
                ansS.push_back(Sub);
                ansN.push_back(i + 1);
                goto End;
                ;
            }
        }
        ansS.push_back(-1);
        ansN.push_back(-1);
    End:;
    }
    for (int i = 0; i < ansS.size(); i++)
    {
        if (ansS[i] == -1)
        {
            cout << "TIE" << endl;
        }
        else
        {
            cout << toC(ansS[i]) << " " << ansN[i] << endl;
        }
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define int long long
#define vi vector<int>
#define vii vector<pair<int,int>>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
int mod=1e9+7;
int max(int a,int b){if(a>b) return a; else return b;}
int max3(int a, int b, int c){ if(a>b){if(a>c) return a; else return c;}else{if(b>c)return b;else return c;}}
int power(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q)
{
	if(p%q==0) return q;
	else
	{
		return gcd(q,p%q);
	}
	
}
signed main()
{
	IOS;
    int t;
    //cin>>t;
	t=1;
    while(t--)
    {
		int n;
		cin>>n;
		int sum=0;
		rep(i,1,n+1)
		{
			rep(j,1,n+1)
			{
				rep(k,1,n+1)
				{
					sum+=gcd((int)i,gcd((int)j,(int)k));
				}
			}
		}
		cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<string>
#include<map>

using namespace std;

int n,k;
string s[1000];
char in[10000];
map<string,bool> Array;


int recroop(string ss,int counter,int index,bool used[]){
  if(counter > k)return 1;
  if(counter == k && !Array[ss]){
    //cout << ss << endl;
    Array[ss]=true; 
  }
  string press = ss;
  bool preused[n];
  for(int i=0;i<n;i++)preused[i]=used[i];

  for(int i=0;i<n;i++){
    if(i != index && !used[i]){
      ss+=s[i];
      used[i]=true;
      recroop(ss,counter+1,i,used);
      used[i]=preused[i];
      ss.clear();
      ss = press;
    }
  }



}


int main(){
  bool used[100];

  while(true){
    cin >> n >> k;
    if(n+k == 0)break;
    for(int i=0;i<100;i++)used[i]=false;
    for(int i=0;i<n;i++)cin >> s[i]; 

    recroop("",0,-1,used); 
      cout << Array.size() << endl;    
      Array.clear();
  }

  return 0;
}

Measured memory_bytes: 1512
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS =1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}

void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}
const int dy[]={-1,0,0,1};
const int dx[]={0,-1,1,0};

typedef pair<pii,pii> ppi;
int used[110][1<<8][21][21];
char field[101][101];
int T;
int gs[101];
int ds[101];
int ss[101];
int es[101];
int ggs[101];
int sums[1<<10];

void solve(){
	int W,H;
	int sy,sx;
	while(cin>>W>>H&&(W|H)){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>field[i][j];
				if(field[i][j]=='P'){
					sy=i;
					sx=j;
					field[i][j]='.';
				}
			}
		}
		cin>>T;
		for(int i=0;i<T;i++){
			cin>>gs[i];
			ggs[gs[i]]=i;
			cin>>ds[i]>>ss[i]>>es[i];
		}
		queue<ppi> q;
		int smask=0;
		int scost=0;
		for(int j=0;j<4;j++){
			int ny=sy+dy[j];
			int nx=sx+dx[j];
			if(ny>=0&&nx>=0&&nx<W&&ny<H&&field[ny][nx]!='.'){
				int id=ggs[field[ny][nx]-'0'];
				if(ss[id]<=0&&es[id]>0){
					smask|=(1<<id);
					scost+=ds[id];
				}
			}
		}
		q.push(make_pair(pii(0,smask),pii(sy,sx)));
		memset(used,-1,sizeof(used));
		used[0][smask][sy][sx]=0;
		while(q.size()){
			ppi p=q.front();q.pop();
			int cmask=p.first.second;
			int ctime=p.first.first;
			int cy=p.second.first;
			int cx=p.second.second;
			//int ctime=used[cmask][cy][cx];
			for(int i=0;i<4;i++){
				int ny=cy+dy[i];
				int nx=cx+dx[i];
				int nmask=cmask;
				int ntime=ctime+1;
				if(ny>=0&&nx>=0&&ny<H&&nx<W&&field[ny][nx]=='.'){
					for(int j=0;j<4;j++){
						int nny=ny+dy[j];
						int nnx=nx+dx[j];
						if(nny>=0&&nnx>=0&&nny<H&&nnx<W&&field[nny][nnx]!='.'){
							int id=ggs[field[nny][nnx]-'0'];
							if(ss[id]<=ntime&&es[id]>ntime&&!((nmask>>id)&1)){
								nmask|=(1<<id);
							}
						}
					}
					if(ntime<=100&&used[ntime][nmask][ny][nx]==-1){
						used[ntime][nmask][ny][nx]=1;
						q.push(make_pair(pii(ntime,nmask),pii(ny,nx)));
					}
				}
			}
		}
		for(int i=0;i<(1<<T);i++){
			sums[i]=0;
			for(int j=0;j<T;j++){
				if((i>>j)&1)
					sums[i]+=ds[j];
			}
		}
		int res=0;
		for(int time=0;time<=100;time++){
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					for(int mask=0;mask<(1<<T);mask++){
						if(used[time][mask][i][j]==-1)continue;
						res=max(res,sums[mask]);
					}
				}
			}
		}
		cout<<res<<endl;
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 48000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

string s[MAXn];
map<string,ll> mp;
int main(){
    IOS();
    ll n;
    cin >> n;
    ll ans = 0;
    REP (i,n) {
        cin >> s[i];
        sort(ALL(s[i]));
        ans += mp[s[i]];
        mp[s[i]]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 16640
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int[][] array = new int[r + 1][c + 1];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				array[i][j] = scan.nextInt();
				array[i][c] += array[i][j];
				array[r][j] += array[i][j];
				array[r][c] += array[i][j];
			}
		}
		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c + 1; j++) {
				System.out.print(array[i][j]);
				if (j != c) {
					System.out.print(" ");
				} else {
					System.out.println();
				}
			}
		}
	}

}

Measured memory_bytes: 42020
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int num[30]={};
  char c;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>c;
    num[c-'a']++;
  }
  
  long long ans=1;
  for(int i=0;i<30;i++)
  {
    ans*=(num[i]+1);
    ans%=1000000007;
  }
  
  cout<<ans-1<<endl;
  
  return 0;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int rr = 0, gg = 0, bb = 0;
	for (char c : s) {
		if (c == 'R')
			rr++;
		if (c == 'G')
			gg++;
		if (c == 'B')
			bb++;
	}
	ll res = (ll)rr * gg * bb;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			int k = 2 * j - i;
			if (s[i] != s[j] && k < n && s[i] != s[k] && s[j] != s[k])
				res--;
		}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 3668
#include <stdio.h>

main()
{
    int a, b, c;
    int s;

    scanf("%d %d %d", &a, &b, &c);

    if(a > b)
    {
        s = a;
        a = b;
        b = s;
    }

    if(b > c)
    {
        s = c;
        c = b;
        b = s;
    }

    if(a > b)
    {
        s = a;
        a = b;
        b = s;
    }

    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2072
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = inp()
aa = inpl()
S = 0
ba = 0
for a in aa:
	S += abs(a-ba)
	ba = a
S += abs(ba)

aa = [0] + aa + [0]
for i in range(1,N+1):
	l,m,r = aa[i-1],aa[i],aa[i+1]
	bc = abs(m-l)+abs(r-m)
	nc = abs(r-l)
	print(S-bc+nc)


Measured memory_bytes: 15124
#include <stdio.h>

int main();
int sub_sum(int start_int, int  num_int);

int main(){
	int input[100] = {0};
	int num_int;
	int start_int;
	int max_int;
	int result[3] = {0};
	int result_temp;
	int sum_result;
	int i,i_dataset;

	
	//データ入力
	i_dataset = 0;
	while(1){
		scanf("%d",&input[i_dataset]);
		if (input[i_dataset]==0) break; //0が入れば読み込み停止
		else i_dataset++; //データ数を記録
	}
	
	//計算開始
	for(i=0;i<i_dataset;i++){ //各データ入力に対する処理を行う
		
		result_temp = 0;
		max_int = input[i];
		
		for(num_int=2; num_int<max_int; num_int++){ //連続範囲の定義
			
			for(start_int=1; start_int < max_int;start_int++){ //開始数最大値の定義
				
				sum_result = num_int * ( start_int + start_int + num_int - 1 ) / 2; //和の計算
				
				if(sum_result > max_int)break; //入力を上回った時点で計算終了
				else if(sum_result == max_int) result_temp++; //入力と一致したらカウント
				
			}
		}
		
		result[i] = result_temp; //カウント結果を格納
	}
	
	for(i=0;i<i_dataset;i++){
		printf("%d\n",result[i]); //結果出力
	}
	return 0;
}



Measured memory_bytes: 2568
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int t;
    int ll,rr;
    long long l,r;
    scanf("%lld %lld",&l,&r);
    int min=2100;
    ll=l%2019;
    rr=r%2019;
    if(ll<rr&&(l/2019==r/2019))
    {
        for(int i=ll;i<rr;i++)
        {
            for(int j=i+1;j<=rr;j++)
            {
                t=(i*j)%2019;
                if(t<min)
                    min=t;
            }
        }
        printf("%d",min);
    }
    else{
        printf("%d",0);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int lucas(int n);

int main(){
    int n;
    cin >> n;
    
    vector<int64_t> s(87);
    
    for(int i = 0; i < n + 1; i++){
        if(i == 0) s[i] = 2;
        else if(i == 1) s[i] = 1;
        else s[i] = s[i - 2] + s[i - 1];
    }
    
    cout << s.at(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vecv(N);
  vector<int> vecc(N);
  
  for(int i = 0; i < N; i++) {
    cin >> vecv.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> vecc.at(i);
  }
  
  vector<int> vecxy(N);
  for(int i = 0; i < N; i++) {
    vecxy.at(i) = vecv.at(i) - vecc.at(i);
  }
  
  int ans = 0;
   for(int i = 0; i < N; i++) {
  if(vecxy.at(i) > 0) {
    ans += vecxy.at(i);
  }
   }
  
  cout << ans << endl;
    
  
  
}

Measured memory_bytes: 256
N = int(input())
ans = []
if N % 2 == 0:
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j != N + 1:
                ans.append((i, j))
else:
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j != N:
                ans.append((i, j))
print(len(ans))
for a in ans:
    print(' '.join(map(str, a)))


Measured memory_bytes: 3700
#include <cstdio>
#include <set>
#include <vector>
using namespace std;

int main(){
  int H, W;
  while(scanf("%d%d", &W, &H)){
    if ((H == 0) && (W == 0)){
      break;
    }
    vector<vector<char> > m(H, vector<char>(W, ' '));
    pair<int,int> start(0,0);
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        scanf(" %c", &(m[i][j]));
        if (m[i][j] == '@'){
          start.first = j;
          start.second = i;
	}
      }
    }
    set<pair<int,int> > q;
    set<pair<int,int> > already;
    q.insert(start);
    while(!q.empty()){
      pair<int,int> next = *(q.begin());
      q.erase(q.begin());
      if (already.find(next) == already.end()){
        already.insert(next);
        if ((next.first > 0) && (m[next.second][next.first-1] == '.')){
          q.insert(pair<int,int>(next.first-1, next.second));
	}
        if ((next.first < W-1) && (m[next.second][next.first+1] == '.')){
          q.insert(pair<int,int>(next.first+1, next.second));
	}
        if ((next.second > 0) && (m[next.second-1][next.first] == '.')){
          q.insert(pair<int,int>(next.first, next.second-1));
	}
        if ((next.second < H-1) && (m[next.second+1][next.first] == '.')){
          q.insert(pair<int,int>(next.first, next.second+1));
	}
      }
    }
    printf("%d\n", (int)already.size());
  }
  return 0;
}

Measured memory_bytes: 1080
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt(),w = scan.nextInt();
		String[] C = new String[h];
		for(int i=0; i<h; i++)C[i] = scan.next();
		for(String c :C)System.out.println(c+"\n"+c);

	}

}

Measured memory_bytes: 23812
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let r: usize = sc.read();
    let result = if n >= 10 { r } else { r + 100 * (10 - n) };
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){	
	int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int res = 2e9;
  for (int x = 1; x <= 100; ++x) {
    int cur = 0;
    for (int e : a) {
      cur += (e - x) * (e - x);
    }
    res = min(res, cur);
  }
  cout << res << '\n';
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define init(a, b) memset(a, b, sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

#define MOD = 1e9+7;

/******* Debugging Class Template *******/
#define DEBUG

#ifdef DEBUG

    #define de(args...)     (Debugger()) , args

    class Debugger
    {
        public:
        Debugger(const std::string& _separator = " - ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std:cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std:cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif





int32_t main()
{
   
    IOS
    
    int k,x;
    cin>>k>>x;
    if(k*500>=x){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100006
using namespace std;
typedef long long ll;
int n,a[MAX],c[MAX],fin;
int main(){
    scanf(" %d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        if(a[i]<=n) c[a[i]]++;
        else fin++;
    }
    for(int i=1;i<=n;i++){
        if(c[i]<i) fin+=c[i];
        else fin+=c[i]-i;
    }
    printf("%d\n",fin);
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

struct UnionFind 
{
    vector <int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    } 
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)]; }
};

vector <int> to[100005];
int deg[100005];

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a, b);
    }

    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for (int i = 0; i < n; i++) {
        int ans = uf.size(i) - 1 - deg[i];
        for (int u : to[i]) {
            if (uf.same(i, u)) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 6784
import java.io.PrintWriter

fun main(args: Array<String>) {

  val pw = PrintWriter(System.out)
  val (k, x) = readLine()!!.split(" ").map{it.toInt()}

  if (500 * k >= x)
    System.out.println("Yes")
  else
    System.out.println("No")
}


Measured memory_bytes: 37848
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

string S;
int main() {
    int i;
    int N,K;
    scanf("%d %d",&N,&K);
    S.resize(N);
    for (i = 0; i < N; i++) scanf(" %c",&S[i]);
    S += S;
    reverse(S.begin()+S.size()/2,S.end());

    string s = S.substr(0,N);
    for (i = 0; i < N; i++) s = min(s,S.substr(i,N));
    for (i = 0; i < N; i++) {
        if (s[i] != s[0]) break;
    }
    int x = i,p = i;
    K--;
    while (K--) {
        x *= 2;
        if (x >= N) break;
    }
    x = min(x,N);
    for (i = 0; i < x; i++) printf("%c",s[0]);
    for (i = 0; i < N-x; i++) printf("%c",s[p+i]);
    printf("\n");

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  vector<int> b(N);
  for (int i = 0; i < N; i++)
    cin >> a[i] >> b[i];
  vector<int> c(M);
  vector<int> d(M);
  for (int i = 0; i < M; i++)
    cin >> c[i] >> d[i];
  for (int i = 0; i < N; i++)
  {
    int id = -1;
    long dist = 10000000000;
    for (int j = 0; j < M; j++)
    {
      long tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (tmp < dist)
      {
        id = j;
        dist = tmp;
      }
    }
    cout << id + 1 << endl;
  }
  return 0;
}

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

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

int n,m;

void solve1(){
	bitset<500> a[30];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 0;i < (1 << n);i++){
		bitset<500> t = 0;
		for(int j = 0;j < n;j++){
			if(i >> j & 1) t ^= a[j];
		}
		if(t == 0) chmax(ans,__builtin_popcount(i));
	}
	cout << ans << endl;
}

int dp[2][1 << 22],*now = dp[0],*nxt = dp[1];

void solve2(){
	int a[510];
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		a[i] = 0;
		for(int j = 0;j < m;j++) a[i] = a[i] * 2 + s[j] - '0';
	}
	const int INF = 1e+9;
	for(int i = 0;i < (1 << m);i++) now[i] = -INF;
	now[0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < (1 << m);j++) nxt[j] = -INF;
		for(int j = 0;j < (1 << m);j++){
			chmax(nxt[j],now[j]);
			chmax(nxt[j ^ a[i]],now[j] + 1);
		}
		swap(now,nxt);
	}
	cout << now[0] << endl;
}

void solve(){
	if(n <= 22) solve1();
	else solve2();
}

signed main(){
	while(cin >> n >> m,n) solve();
}


Measured memory_bytes: 19624
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, l, r;
    while (cin >> n) {
        int ans = 0;
        while (n--) {
            cin >> l >> r;
            ans += r - l + 1;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    priority_queue<long long> l;
    priority_queue<long long, vector<long long>, greater<long long>> r;
    long long lsum = 0; long long rsum = 0; long long b = 0;
    while (q--) {
        int type; cin >> type;
        if (type == 1) {
            long long a, bb; cin >> a >> bb;
            b += bb;
            if (!l.empty() && l.top() < a) {
                rsum += a;
                r.push(a);
            } else {
                lsum += a;
                l.push(a);
            }
            while ((int) l.size() - (int) r.size() < 0) {
                long long u = r.top();
                lsum += u; l.push(u);
                rsum -= u; r.pop();
            }
            while (l.size() - r.size() > 1) {
                long long u = l.top(); l.pop();
                lsum -= u; rsum += u; r.push(u);
            }
        } else {
            long long x = l.top();
            long long sum = x * l.size() - lsum;
            sum += rsum - x * r.size();
            // cout << " " << lsum << " " << rsum << endl;
            cout << x << " " << sum + b << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll need_left = 0;
    ll pointer = 0;
    rep(i,s.size()){
        if(s[i]=='(') pointer++;
        else {
            if(pointer==0) need_left++;
            else pointer--;
        }
    }

    ll need_right = need_left;
    string res = "";
    rep(i,need_left) res += '(';
    res += s;
    rep(i,pointer) res += ')';
    cout<<res<<endl;
    return 0;
}

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

int f(int n){
    int sum = 0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main() {
    int n,a,b;
    cin>>n>>a>>b;
    int res =0;
    for(int i=1;i<=n;i++){
        int sum = f(i);
        if(sum>=a && sum<=b) res+=i;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = []
for i in range(n+1):
    a = [i//10000,(i//1000)%10,(i//100)%10,(i//10)%10,i%10]
    if x <= sum(a)  <= y:s. append(i)
print(sum(s))

Measured memory_bytes: 13676
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, c = map(int, input().split())
    # v: cumulative sum
    x, v = [0] * (n+2), [0] * (n+2)
    for i in range(n):
        j, k = map(int, input().split())
        x[i+1] = j
        v[i+1] = v[i] + k
    x[n+1] = c
    v[n+1] = v[n]
    
    max_nut_clockwise = [0] * (n+1)
    for i in range(1, n+1):
        max_nut_clockwise[i] = max(max_nut_clockwise[i-1], v[i] - x[i])
    max_nut_counterclockwise = [0] * (n+1)
    for i in range(n-1, -1, -1):
        max_nut_counterclockwise[i] = max(max_nut_counterclockwise[i+1], v[-1] - v[i] - c + x[i+1])

    ans = 0
    # rotate clockwise, then rotate counterclockwise
    for i in range(n):
        if ans < v[i] - 2*x[i] + max_nut_counterclockwise[i]:
            ans = v[i] - 2*x[i] + max_nut_counterclockwise[i]
    # rotate counterclockwise, then rotate clockwise
    for i in range(2, n+2):
        if ans < v[-1] - v[i-1] - 2 * (c - x[i]) + max_nut_clockwise[i-1]:
            ans = v[-1] - v[i-1] - 2 * (c - x[i]) + max_nut_clockwise[i-1]
    
    print(ans)

main()

Measured memory_bytes: 77508
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n; cin >> n;
    vector<int> a(n); FOR(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());
    ll comfort = 0;
    queue<int> que;
    que.push(a[0]);
    FOR(i, 1, n) {
        comfort += que.front();
        que.pop();        
        que.push(a[i]);
        que.push(a[i]);
    }
    cout << comfort << endl;
}

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

Measured memory_bytes: 4780
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    if (S[0] != 'A') {
        cout << "WA" << endl;
    } else {
        ll num = 0;
        for (ll i = 2; i < S.size() - 1; i++) {
            if (S[i] == 'C') {
                num++;
            }
        }
        if (num != 1) {
            cout << "WA" << endl;
            return 0;
        }
        for (ll i = 1; i < S.size(); i++) {
            if (S[i] != 'C' && 'A' <= S[i] && S[i] <= 'Z') {
                cout << "WA" << endl;
                return 0;
            }
        }

        cout << "AC" << endl;
    }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int maxv = 0;
  int sum = 0;
  int l;
  rep(i,n){
    cin >> l;
    sum += l;
    maxv = max(maxv,l);
  }
  if(maxv<sum-maxv)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256