akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		rep(j, s.size() - 1) {
			swap(s[j], s[j + 1]);
		}
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
int a,b,c;
inline void _Sol_()
{
	read(a);read(b);read(c);
	if(a==b&&a!=c){
		puts("Yes");return;
	}
	if(a==c&&a!=b){
		puts("Yes");return;
	}
	if(b==c&&a!=b){
		puts("Yes");return;
	}
	puts("No");
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int i, j, n, min, max, temp;
	int a[200000];

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	min = a[0];
	max = -999999999;

	for (i = 1; i < n; i++)
	{
		temp = a[i] - min;
		if (max < temp)
			max = temp;
		if (min > a[i])
			min = a[i];
	}

	printf("%d\n", max);

	return 0;

}


Measured memory_bytes: 2648
#include"bits/stdc++.h"
using namespace std;
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i!=s.size()-1;++i){
		string a=s.substr(0,i),b=s.substr(i);
		int cur=0;
		set<int> x,y;
		for(auto i:a)
			x.insert(i);
		for(auto i:b)
			y.insert(i);
		for(auto i:x){
			if(y.find(i)!=y.end())
				++cur;
		}
		ans=max(cur,ans);
	}
	cout<<ans;
}
 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = long.Parse(Read.Str());
        
        long ans = 1;
        for (long i1 = 2; i1 <= n; i1++)
        {
            if (IsPrime(i1))
            {
                long ans1 = 1;
                for (long i = i1; i <= n; i += i1)
                {
                    long y = i;
                    while (y % i1 == 0)
                    {
                        y /= i1;

                        ans1++;
                  //      if (y % i1 != 0) { break; }
                    }
                }
                ans %= (long)(Math.Pow(10,9)+7);
                ans *= ans1;
            }
        }
        ans %= (long)(Math.Pow(10, 9) + 7); Console.WriteLine(ans);
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a %= b; }
            else { b %= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static string Reverse(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(long num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

       for (long i = 3; i*i <= num; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
    opt;
    lli n,m;
    cin>>n>>m;
    vplli v,v1;
    lli x,y,x1,y1;
    while(n--)
    {
        cin>>x>>y;
        v1.pb(mp(x,y));
    }
    while(m--)
    {
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    lli j,i;
    rep(i,0,v1.sz())
    {
        lli ans=1000000000,index=-1,x=v1[i].f,y=v1[i].s;
        rep(j,0,v.sz())
        {
            x1=v[j].f;
            y1=v[j].s;
            lli dis=abs(x-x1)+abs(y-y1);
            if(dis<ans)
            {
                ans=dis;
                index=j;
            }
        }
                    cout<<index+1<<endl;
    }

}




Measured memory_bytes: 256
#include <stdio.h>
#define max 100
#define white 1
#define gray 2
#define black 3
typedef struct{
  int num; //頂点の番号を表す。
  int degree; //出次数を表す。
  int Adj[max]; //隣接リスト(隣接する頂点の番号のリスト)。
  int color;
  int dtime; //最初に発見された時刻を表す。
  int ftime; //隣接リストを調べ終えた完了時刻を表す。
} node;
int n, time, A[max+1][max+1];
void dfs(node *);
void visit(int, node *);

int main()
{
  //深さ優先探索のプログラム
  int i, j;
  node node[max];
  
  for(i = 0 ; i <= max ; i++){
    for(j = 0 ; j <= max ; j++) A[i][j] = 0; }

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&node[i].num,&node[i].degree);
    for(j = 0 ; j < node[i].degree ; j++){
      scanf("%d",&node[i].Adj[j]);
      A[node[i].num][node[i].Adj[j]] = 1; }
  }

  dfs(node);

  for(i = 0 ; i < n ; i++) printf("%d %d %d\n",node[i].num,node[i].dtime,node[i].ftime);
  
  return 0;
}

void dfs(node *node)
{
  int i;

  for(i = 0 ; i < n ; i++) node[i].color = white;

  time = 0;

  for(i = 0 ; i < n ; i++){
    if(node[i].color == white) visit(i, node); }
      
}

void visit(int u, node *node)
{
  int i, j, index;
  
  node[u].color = gray;
  node[u].dtime = ++time;

  for(i = 0 ; i < node[u].degree ; i++){
    for(j = 0 ; j < n ; j++){
      if(node[u].Adj[i] == node[j].num) index = j; }
    if(A[node[u].num][node[u].Adj[i]] == 1 && node[index].color == 1) visit(index, node); }
    
  node[u].color = black;
  node[u].ftime = ++time;

}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

int main() {
  string s; cin >> s;
  stack<string> st;
  rep(i, 0, (int)s.size()) {
    if (s[i] == 'm') {
      st.push("m");
    } else if (s[i] == 'e') {
      if (st.size() > 0 && st.top() == "m") {
        st.pop();
        st.push("me");
      } else {
        cout << "Rabbit" << endl;
        return 0;
      }
    } else {
      if (st.size() > 0 && st.top() == "me") {
        st.pop();
        if (st.size() == 0 && i < (int)s.size() - 1) {
          cout << "Rabbit" << endl;
          return 0;
        }
      } else {
        cout << "Rabbit" << endl;
        return 0;
      }
    }
  }
  cout << "Cat" << endl;
}

//////////////////////////////////////////////////////////////////////////
//NOTE
//////////////////////////////////////////////////////////////////////////
// "(" と ")"が対応できてるかみたいな問題と同じ解き方.
// stack<string> を用いて解く.
// ただし、いつもと違って、CAT + CATみたいな文はどうやらダメらしいので
// stackのサイズが0になって、かつ今見ているindexがst.size() - 1より小さかったらRabbit
// と出力するようにする.


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<algorithm>
#include <cstring>
using namespace std;

int main()
{

	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N,i,j,flag=1,count=0;
  scanf("%d",&N);
  int bubble[N];
   for(j=0;j<N;j++)
    {
      scanf("%d",&bubble[j]);
    }
  while(flag)
    {
      flag=0;
      for(j=N-1;j>0;j--)
	{
	  if(bubble[j]<bubble[j-1])
	    {
	      count++;
	      i=bubble[j];
	      bubble[j]=bubble[j-1];
	      bubble[j-1]=i;
	      flag=1;
	    }
	}
    }
  for(j=0;j<N-1;j++)
    {
      printf("%d ",bubble[j]);
    }
  printf("%d\n",bubble[N-1]);
  printf("%d\n",count);
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for( int i=0; i<n; i++ ){
        cin >> arr[i];
    }
    for( int j=1; j<n; j++ ){
        cout << arr[0];
        for( int i=1; i<n; i++ ){
            cout << " " << arr[i];
        }
        cout << endl;
        int key = arr[j];
        int i = j-1;
        while( i>=0 && arr[i]>key ){
            arr[i+1] = arr[i];
            i--;
        }
        arr[i+1] = key;
    }
    cout << arr[0];
    for( int i=1; i<n; i++ ){
        cout << " " << arr[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1196
<>;$x=$==-1,s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$=*=$&**(-$a%3)/ge,++$h{$x},$$x=$=for`factor`;$\+=$_+1?$h{$_}:!!$h{$_},$h{$_}=$h{$$_}=0for sort{$h{$b}-$h{$a}}keys%h;print

Measured memory_bytes: 71248
N = int(input())
L = list(map(int, input().split()))
L.sort()

res = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i]==L[j]:
        0
      elif L[j]==L[k]:
        0
      elif L[i]+L[j]>L[k]:
        res = res+1
      else:
        0

print(res)

Measured memory_bytes: 9208
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    
    long long m = max(max(a*c,a*d),max(b*c,b*d));
    
    if(m<0 && ( (a<=0&&b>=0) || (c<=0&&d>=0) ) ){
        cout<<0;
    }
    else{
        cout<<m;
    }
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll a,b,count=0;
    vector<ll> c;
    cin >> a >> b;
    if(a < 0 && b > 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(a == 0 || b == 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }
    if(a < 0 && b < 0){
        ll d = abs(a-b);
        if(d%2 == 0){
            cout << "Negative" << endl;
            return 0;
        }else{
            cout << "Positive" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int s,w;
  cin >> s >> w;
  cout << (s<=w ? "unsafe\n" : "safe\n");
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll solve(ll H){
  if(H==1) return 1;
  return 1+2*solve(H/2);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H;
  IN(H);

  OUT(solve(H));


  return 0;
}

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    int x[4],y[4];
    for(int i = 0; i < 4; i++) {
        cin >> x[i] >> y[i];
    }
    
    x[2] = x[1] - (y[1] - y[0]);
    y[2] = y[1] + (x[1] - x[0]);
    x[3] = x[2] - (x[1] - x[0]);
    y[3] = y[2] - (y[1] - y[0]);
    
    cout << x[2] << ' ' << y[2] << ' ' << x[3] << ' ' << y[3] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

can_view = [0]

for i in range(N):
    if i == 0:
        continue
    
    count = 0
    for j in range(i):
        if H[i] >= H[j]:
            count += 1
    
    if count == i:
        can_view.append(i)
print(len(can_view))

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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INf = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  ll q, count = 0;
  cin >> q;

  string add_back = "", add_front = "";
  rep(i, 0, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      count++;
    } else {
      int f;
      char C;
      cin >> f >> C;
      if ((f == 1 && count % 2 == 0) || (f == 2 && count % 2 == 1)) {
        add_back = C + add_back;
      } else {
        add_front = add_front + C;
      }
    }
  }

  if (count % 2 == 1) {
    reverse(s.begin(), s.end());
    reverse(add_front.begin(), add_front.end());
    reverse(add_back.begin(), add_back.end());
    s = add_front + s + add_back;
  } else {
    s = add_back + s + add_front;
  }

  cout << s << endl;
}

Measured memory_bytes: 1512
Ns = list(map(int,input().split()))
if (Ns[2]- Ns[4] >= 0) and (Ns[2] + Ns[4] <= Ns[0]) and (Ns[3] - Ns[4] >= 0) and (Ns[3] + Ns[4] <= Ns[1]):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b, ab;
  cin >> a >> b;
  ab = a * b;
  
  if ((ab % 2) == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    string s,t;
    cin >> s >> t;
    int count = 0;

    for(int i = 0; i < 3;i++){
        if(s[i] == t[i]){
            count++;
        }
    }

    cout << count << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{

  while( true ) {
    int n;
    cin >> n;
    if( n == 0 ) {
      break;
    }

    double sum = 0;
    double d = 0;
    vector<double> dat( 0 );
    for( int i = 0; i < n; i++ ) {
      cin >> d;
      dat.push_back( d );
      sum += d;
    }

    double ave = sum / n;
    double buf = 0, stdev;
    for( int i = 0; i < n; i++ ) {
      buf += pow( dat[ i ] - ave, 2 );
    }
    stdev = sqrt( buf / n );
    cout << fixed << setprecision(8);
    cout << stdev << endl;
  }

  return 0;
}

Measured memory_bytes: 3228
N = int(input())
S = [0] * N

ACcount = 0
WAcount = 0
TLEcount = 0
REcount = 0

for i in range(N):
    S[i] = [str (x) for x in input()]

for x in range(len(S)):
    if S[x] == ['A', 'C']:
        ACcount += 1
    elif S[x] == ['W','A']:
        WAcount += 1
    elif S[x] == ['T','L','E']:
        TLEcount += 1
    elif S[x] == ['R','E']:
        REcount += 1

print("AC x " + str(ACcount))
print("WA x " + str(WAcount))
print("TLE x " + str(TLEcount))
print("RE x " + str(REcount))

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


int main()
{
	char a[200001], b[200001];
	int c[30], i = 0;

	cin >> a >> b;

	for (int j = 0; j < 30; j++) {
		c[j] = -1;
	}

	while (a[i] != 0 && b[i] != 0) {
		if (c[a[i] - 'a'] == -1) {
			c[a[i] - 'a'] = b[i] - 'a';
		}
		else {
			if (c[a[i] - 'a'] != b[i] - 'a') {
				cout << "No";
				return 0;
			}
		}
		i++;
	}

	i = 0;
	for (int j = 0; j < 30; j++) {
		c[j] = -1;
	}

	while (a[i] != 0 && b[i] != 0) {
		if (c[b[i] - 'a'] == -1) {
			c[b[i] - 'a'] = a[i] - 'a';
		}
		else {
			if (c[b[i] - 'a'] != a[i] - 'a') {
				cout << "No";
				return 0;
			}
		}
		i++;
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;
struct I{
    I(){
        ios::sync_with_stdio(false);cin.tie(0);
        //cout<<fixed<<setprecision(10);
    }
}init;

typedef long long LL;
const LL MOD=1e9+7;

#define SPACE " "
template<typename T>
ostream& operator<<(ostream &os,vector<T> v){
    for(int i =0,sz=v.size();i<sz;i++)os<<(!i)+SPACE<<v[i];
    return os;
}
template<typename T>
istream& operator>>(istream &is,vector<T>& v){
    for(int i =0,sz=v.size();i<sz;i++)is>>v[i];
    return is;
}


int main(){
    int R,C;
    cin>>R>>C;
    vector<string> a(R,string(C,'.'));
    auto b=a;
    for(int r=0;r<R;r+=2)
        for(int c=1;c<C;c++)
            a[r][c]='#';
    for(int r=0;r<R;r++)
        a[r][C-1]='#';

    for(int r=1;r<R;r+=2)
        for(int c=0;c<C-1;c++)
            b[r][c]='#';
    for(int r=0;r<R;r++)
        b[r][0]='#';

    vector<string> s(R);
    cin>>s;
    for(int r=0;r<R;r++)
        for(int c=0;c<C;c++)
            if(s[r][c]=='#')a[r][c]=b[r][c]='#';
    for(int i=0;i<R;i++)cout<<a[i]<<endl;
    cout<<endl;
    for(int i=0;i<R;i++)cout<<b[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 1536
S=input()[::-1]
l=len(S)
a=1
m=10**9+7
dp=[1]+[0]*12
for d in S:
    dp2=[0]*13
    if d=='?':
        for j in range(13):
            for k in range(10):
                dp2[(j+k*a)%13]+=dp[j]%m
    else:
        for j in range(13):
            dp2[(j+int(d)*a)%13]=dp[j]
    dp=dp2
    a=(a*10)%13 if a!=1 else 10
print(dp[5]%m)

Measured memory_bytes: 43756
#include <iostream>  
#include <cstdio>  
#include <algorithm>  
#include <set>  
#include <string>  
#include <cstring>  
#include <cmath>  
#include <map>  
#define N 505  
using namespace std;  
typedef long long ll;  
int c[505]; 
int s[505]; 
int f[505]; 
int main()  
{  
    int n;  
    scanf("%d",&n);  
    for(int i=1;i<=n;i++)  
        scanf("%d%d%d",&c[i],&s[i],&f[i]);  
    for(int i=1;i<=n;i++){  
        int ans=0;  
        for(int j=i;j<n;j++){  
            if(ans<s[j])  
                ans=s[j];  
            if(ans%f[j]!=0) 
                ans=ans+f[j]-ans%f[j];  
            ans+=c[j];  
        }  
        printf("%d\n",ans);  
    }  
}  


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

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    static int64_t dp[200001][6];
    for(int i=0; i<=N; i++) for(int j=0; j<3; j++) dp[i][j] = -1e18;
    for(int i=0; i<=2; i++) if(i<N) dp[i][i] = A[i];
    for(int i=0; i<N; i++) for(int j=0; j<3; j++){
        for(int d=0; j+d<3; d++){
            int bef = i-2-d;
            if(bef < 0) continue;
            chmax(dp[i][j+d], dp[bef][j] + A[i]);
        }
    }
    int64_t ans = -1e18;
    int D = 1 + N%2;
    for(int d=0; d<=D; d++){
        int i = N-1-d;
        if(i >= 0) chmax(ans, dp[i][D-d]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13500
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
	string name,a; 


int main(){
	int N,count=0;

	cin>>N;
	cin>>name;//name=bar:a=abracadabra
	bool flag=0;
	
	for(int i=0;i<N;i++){
	cin>>a;
	for(int i=0;i<a.size();i++){
		for(int j=0;j<a.size();j++)	{
			string test="";	
			for(int k=i;test.size()<name.size();k+=j+1){
				if(k>=a.size())break;
				test+=a[k];
			}
			if(test==name){
				count++;
				goto next;		
			}
		}
	}
	
	next:;
	}	
	cout<<count<<endl;
return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e9 
typedef long long ll;
typedef long double ld;
int main(){
    string str;
    cin>>str;
    int size=SIZE(str);
    vector<char> v={'N', 'S', 'W', 'E'};
    vector<int> cnt(4);
    REP(i,size){
        char c;
        c=str[i];
        REP(j,4){
            if(c==v[j])cnt[j]++;
        }
    }
    int n=cnt[0], s=cnt[1], w=cnt[2], e=cnt[3];
    bool isv, ish;
    if(n*n+s*s==0)isv=true;
    else if(n*s==0)isv=false;
    else isv=true;
    if(w*w+e*e==0)ish=true;
    else if(w*e==0)ish=false;
    else ish=true;
    string ans=(isv&&ish)?"Yes":"No";
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  map<int, ll> mp;
  rep(i, 0, N) {
    int a;
    ll b;
    cin >> a >> b;
    mp[a] += b;
  }
  for(auto &p : mp) {
    K -= p.second;
    if(K <= 0) {
      cout << p.first << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e4+5;

int main(){
	long long n, nt; cin >> n;
	nt = sqrt(n);
	long long ans, a, y, tem = inf;
	for(int i = nt; i >= 1; i--){
		if(n % i == 0){
			y = n / i;
			ans = y + i - 2;
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int i=0;
	int n = s.size();
	if(n%2)
	{
		cout << "No" << endl;
		return 0;
	}
	while(i<(n/2))
	{
		if((s[i] == 'b' && s[n-i-1] == 'd') || (s[i] == 'd' && s[n-i-1] == 'b') || (s[i] == 'p' && s[n-i-1] == 'q') || (s[i] == 'q' && s[n-i-1] == 'p'))
		{
			i++;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 512
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int h, w; cin>>h>>w;
    int a[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>a[i][j];
        }
    }

    int ans=1e9;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){

            int sum=0;
            for(int y=0; y<h; y++){
                for(int x=0; x<w; x++){
                    sum += a[y][x] * min(abs(i - y), abs(j - x));
                }
            }

            chmin(ans, sum);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3084
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        t: usize,
        a: [usize; n],
    }

    let mut minv = a[0];
    let mut maxdiff = 0;
    for i in 0..a.len() {
        minv = min(minv, a[i]);
        maxdiff = max(maxdiff, a[i] - minv);
    }
    let mut ans = 0;
    minv = a[0];
    for i in 0..a.len() {
        minv = min(minv, a[i]);
        if a[i] - minv == maxdiff {
            ans += 1;
        }
    }
    ans.p();
}


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


int F[50];

int main() {
  int N, M;
  cin >> N >> M;
  for(int i=0; i<N; ++i) {
    int K;
    cin >> K;
    for(int j=0; j<K; ++j) {
      int a;
      cin >> a;
      ++F[a];
    }
  }

  int ans = 0;
  for(int i=0; i<M+1; ++i) {
    if(F[i] == N) ++ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt(), k = sc.nextInt();
            if(n==0 && k==0) break;
            int[] card = new int[k];
            for(int i=0; i<k; i++){
                card[i] = sc.nextInt();
            }
            Arrays.sort(card);

            LinkedList<Integer> list = new LinkedList<Integer>();
            boolean boo = false;
            int begin = -1, end = -1;
            for(int i=0; i<k; i++){
                if(card[i]==0){
                    boo = true;
                    continue;
                }
                if(begin==-1){
                    begin = card[i];
                    end = card[i];
                }else if(end==card[i]-1){
                    end = card[i];
                }else{
                    list.add(new Integer(begin));
                    list.add(new Integer(end));
                    begin = card[i];
                    end = card[i];
                }
            }
            if(begin!=-1){
                list.add(new Integer(begin));
                list.add(new Integer(end));
            }

            int maxLen = 0;
            if(!boo){
                for(int i=0; i<list.size(); i++){
                    int n1 = list.poll();
                    int n2 = list.poll();
                    maxLen = Math.max(maxLen, n2-n1+1);
                }
            }else{
                int n1 = list.poll();
                int n2 = list.poll();
                for(int i=0; i<list.size(); i++){
                    int n3 = list.poll();
                    int n4 = list.poll();
                    if(n2==n3-2) maxLen = Math.max(maxLen, n4-n1+1);
                    n1 = n3;
                    n2 = n4;
                }
            }
            System.out.println(maxLen);
        }
    }

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

Measured memory_bytes: 61656
n = int(input())
a = list(map(int, input().split()))

# The 'acc' stands for accumulation.
acc = []
acc.append(a[0])
for i in range(n - 1):
    acc.append(acc[i] + a[i + 1])

# b: border, s: sum
s = [0, 0, 0, 0]
b0 = 0
b2 = 2
score = []
for b1 in range(1, n - 2):
    for i in range(b1 - b0 - 1):
        b0 = b0 + 1
        if (abs(acc[b1] - acc[b0] * 2) > abs(acc[b1] - acc[b0 - 1] * 2)):
            b0 = b0 - 1
            break
    s[0] = acc[b0]
    s[1] = acc[b1] - acc[b0]

    for i in range(n - b2 - 2):
        b2 = b2 + 1
        if (abs(acc[n - 1] - acc[b2] * 2 + acc[b1]) > abs(acc[n - 1] - acc[b2 - 1] * 2 + acc[b1])):
            b2 = b2 - 1
            break
    s[2] = acc[b2] - acc[b1]
    s[3] = acc[n - 1] - acc[b2]

    score.append(max(s) - min(s))

print(min(score))


Measured memory_bytes: 29140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126A
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = input[0];
            int K = input[1];

            string S = Console.ReadLine();

            string ans = "";
            for(int i = 1; i <= N; i++)
            {
                if (i == K) ans += S.ToLowerInvariant()[i - 1];
                else ans += S[i - 1];
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> m;
    rep(i, N) {
        cin >> A[i];
        m[A[i]]++;
    }

    sort(all(A));
    ll ma = A[N - 1];
    ll ans = 0;
    vector<bool> div(ma + 5, false);
    rep(i, N) {
        if (!div[A[i]] && m[A[i]] == 1)
            ans++;
        for (int j = A[i]; j < ma + 5; j += A[i]) {
            div[j] = true;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17588
#include <stdio.h>
#include <algorithm>

#define LIM_S 12
#define LIM_N 10002

char str[200002];

int N;
char s[LIM_N][LIM_S];

int s_len[LIM_N];
int s_ab[LIM_N];

int bxa;
int bxx;
int xxa;
int xxx;

int is_head_b(int n) {
	return s[n][0] == 'B';
}

int is_tail_a(int n) {
	return s[n][s_len[n]-1] == 'A';
}

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	for (size_t i = 0; i < N; i++) {
		scanf("%s", s[i]);
	}
}

void initialize() {
	for (size_t i = 0; i < N; i++) {
		int len = 0;
		while (s[i][++len]) {
			if (s[i][len-1] == 'A' && s[i][len] == 'B') {
				s_ab[i]++;
			}
		}
		s_len[i] = len;
	}

	for (size_t i = 0; i < N; i++) {
		if (is_head_b(i) && is_tail_a(i)) {
			bxa++;
		} else if (is_head_b(i)) {
			bxx++;
		} else if (is_tail_a(i)) {
			xxa++;
		} else {
			xxx++;
		}
	}
}

int main(void) {
	receive_input();
	initialize();

	int sum = 0;

	for (size_t i = 0; i < N; i++) {
		sum += s_ab[i];
	}

	if (xxa > 0) {
		xxa--;
		sum += bxa;
		bxa = 0;
		if (bxx > 0) {
			bxx--;
			sum++;
		}
	} else if (bxa > 0) {
		bxa--;
		sum += bxa;
		bxa = 0;
		if (bxx > 0) {
			bxx--;
			sum++;
		}
	}

	sum += xxa < bxx ? xxa : bxx;

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


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		while (true){

			c -= b;
			if (c <= 0){
				break;
			}
			a -= d;
			if (d <=0) {
				break;
			}
		}
		if (a > 0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 27032
import java.util.Scanner;

public class Main {

	void main() {

		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println((a*b) + " " + (2*a + 2*b));
		}
	}

	public static void main(String[] args) {

		new Main().main();

	}

}



Measured memory_bytes: 26152
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
 

int main() {
	int w[100];
	int N, sum1 = 0, sum2 = 0;
 
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &w[i]);
		sum1 += w[i];
	}
	int delta = 100000;
	for (int i = 0; i < N; i++) {
		sum2 += w[i];
		sum1 -= w[i];
		if (sum1 -sum2 > 0 && sum1 - sum2 < delta)delta = sum1 - sum2;
		else if (sum2 - sum1 < delta)
		{
			delta = sum2 - sum1;
			
		}
	}
	printf("%d", delta);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define ALL(v) v.begin(), v.end()

string calc(string a, string b);

int main()
{
	int n;
	string a,b;
	scanf("%d", &n);
	
	while(n--){
		cin >> a >> b;
		cout << calc(a,b) << endl;
	}
	return(0);
}

string calc(string a, string b)
{
	reverse(ALL(a));
	reverse(ALL(b));
	
	while(a.size() < b.size()) a += '0';
	while(b.size() < a.size()) b += '0';
	
	int c = 0;
	string res;
	
	for(int i = 0; i < a.size(); i++){
		c = c+a[i] - '0' + b[i] - '0';
		res += c%10 + '0';
		c /= 10;
	}
	if(c)res += c + '0';
	if(res.size() > 80) return "overflow";
	reverse(ALL(res));
	return res;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int a,b;
    cin>>a>>b;
    long long int result = 0;
    if(a==1||b==1){
        cout << 1 << endl;
        return 0;
    }
    result += ((a + 1ll)/2ll) *( (b + 1ll) / 2ll);
    result += (a/2ll) * (b / 2ll);
    cout << result << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int arr[400];
  for(int i=0;i<n;i++) cin>>arr[i];
  
  pair<long,long> dp[401][401];
  
  for(int i=0;i<=400;i++){
    for(int j=0;j<=400;j++){
      dp[i][j].first=0;
       dp[i][j].second=0;
    }
  }
  for(int i=1;i<=n;i++){
   dp[i][i].first=arr[i-1];
    dp[i][i].second=0;
  }
  for(int i=1;i<n;i++){
    for(int j=1;j<=n-i;j++){
      long sum=LONG_MAX,cost=LONG_MAX;
      for(int k=1;k<=i;k++){
           long s=dp[j][j+k-1].first+dp[j+k][i+j].first;
           long c=dp[j][j+k-1].second+dp[j+k][i+j].second+s;
          if(c<cost){
           cost=c;
            sum=s;
          }
      }
      dp[j][i+j].first=sum;
      dp[j][i+j].second=cost;
    //  cout<<dp[j][i+j].second<<" ";
    }
  //  cout<<endl;
  }
  cout<<dp[1][n].second;
}
  
  

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

int main() {
  int k,n,c;
  int a[200000] = {0};
  cin >> k >> n; 
  for (int i=0; i < n; i++){
    cin >> a[i];
  }
  c = k - a[n-1];
  int sum = 0;
  int max = 0;
  for(int i=0;i< n-1; i++){
    sum += a[i+1]-a[i];
    if(a[i+1]-a[i]>a[max+1]-a[max]) max = i;
  }
  if(k-a[n-1]+a[0]<a[max+1]-a[max]){
      sum += k-a[n-1]+a[0]; 
      sum -= a[max+1]-a[max];
  }
  cout << sum << endl;
}

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

int main(){
  long int N, K, Q;
  cin >> N >> K >> Q;
  vector<long int> people(100010, K);
  vector<long int> answer;
  
  for(int i=0;i<Q;i++){
    int A;
    cin >> A;
    people[A-1]++;
  }
  
  for(int i=0;i<N;i++){
    people[i] -= Q;
  }
  
  for(int i=0;i<N;i++){
    if(people[i] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int d;
  cin >> d;
  int c[26];
  for(int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  vector<vector<int>> s(d, vector<int>(26));
  for(int i = 0; i < d; i++) {
    for(int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> last(26, 0);
  int score = 0;
  for(int i = 0; i < d; i++) {
    int idx = 0;
    int maxi = 0;
    for(int j = 0; j < 26; j++) {
      int tmp = c[j] * ((i + 1) - last[j]) + s[i][j];
      if(tmp > maxi){
        maxi = tmp;
        idx = j;
      }
    }
    last[idx] = i + 1;
    cout << idx + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
int solve(int,int);
int n,A[2000];
int main(){
  int q,m[2000],i,j=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&m[i]);

  for(i=0;i<q;i++){
    if(solve(j,m[i])==0) printf("yes\n");
    else printf("no\n");
    
  }

  return 0;
}

int solve(int j,int m){
  int res;
  //printf("%d\n",m);
  if(m==0) return 0;
  else if(j>n) return 1;
  
  if((solve(j+1,m-A[j])==0) || (solve(j+1,m)==0)) res=0;
  else res=1;
  return res;
}



Measured memory_bytes: 2048
#include <stdio.h>
#include <vector>
#include <queue>

using namespace std;

int main()
{
  int n,q,c,t,x;
  vector<queue<int> > a;

  scanf("%d", &n);
  scanf("%d", &q);


  for (int i = 0; i < n; i++) {
    a.emplace_back();
  }


  for (int i = 0; i < q; i++) {
    scanf("%d", &c);
    scanf("%d", &t);
    if (c == 0){
      scanf("%d", &x);
      a[t].push(x);
    }else if (c == 1){
      if (a[t].empty()==0){ //空：１　
        printf("%d\n",a[t].front());
      }
    }else if (c == 2){
      if (a[t].empty()==0){ //空：１　
        a[t].pop();
      }
    }

  }
  return 0;
}



Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){

  ll n;
  cin >> n;
  vector<ll> a(n),sum(n+1,0);
  FOR(i,0,n)cin>>a[i];
  FOR(i,0,n)sum[i+1]+=a[i]+sum[i];

  ll ans = INF;

  FOR(i,1,n){
    ll a = sum[i];
    ll b = sum[n] - sum[i];
    ans = min(ans,abs(a-b));
  }

  cout << ans << endl;

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b ; 
    cout << (h - a) * (w - b) << '\n';
    return 0;
}


Measured memory_bytes: 256