akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    string s;
    int q;
    cin >> s >> q;
    deque<char> deq(s.begin(), s.end());
    int tp = 1;
    while (q--)
    {
        int cmd, x;
        char ch;
        cin >> cmd;
        if (cmd == 1)
            tp = 1 - tp;
        if (cmd == 2)
        {
            cin >> x >> ch;
            if (x == 1)
            {
                if (tp == 1)
                    deq.push_front(ch);
                else
                    deq.push_back(ch);
            }
            else if (x == 2)
            {
                if (tp ==0)
                    deq.push_front(ch);
                else
                    deq.push_back(ch);
            }
        }
        
    }
    if (tp == 1)
        {
            while (!deq.empty())
            {
                cout << deq.front();
                deq.pop_front();
            }
        }
        else
        {
            while (!deq.empty())
            {
                cout << deq.back();
                deq.pop_back();
            }
        }
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T-- > 0)
        solve();
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   string s;
   cin>>s;
   if(s[2] == s[3] && s[4] == s[5])
     cout<<"Yes";
   else
     cout<<"No";
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

#define MOD 1000000007

long long power(long long base, long long exponent) {
    long long res = 1;
    while (exponent > 0) {
        if (exponent & 1)
            res = res * base % MOD;
        exponent >>= 1;
        base = base * base % MOD;
    }
    return res;
}

long long mul(long long from, long long to) {
    long long res = 1;
    for (long long i = from; i <= to; i++)
        res = res * i % MOD;
    return res;
}

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

    int n, a, b;
    cin >> n >> a >> b;

    long long ans = power(2, n) - 1;

    /*
      (a - b) mod n = a mod n + (-b) mod n

      The % operator in C is not the modulo operator but the remainder operator.
      Modulo and remainder operators differ with respect to negative values.
      With a remainder operator, the sign of the result is the same as the sign of the dividend while with a modulo operator the sign of the result is the same as the divisor.

      C defines the % operation for a % b as: a == (a / b * b) + a % b

      (From: https://stackoverflow.com/a/11720975)
    */
    ans -= mul(n - a + 1, n) * power(mul(1, a), MOD - 2) % MOD;
    if (ans < 0)
        ans += MOD;

    ans -= mul(n - b + 1, n) * power(mul(1, b), MOD - 2) % MOD;
    if (ans < 0)
        ans += MOD;

    cout << ans % MOD << '\n';

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int H;
int field[10][6]={};

ll solve(){
	ll res = 0;
	rep(i,H){
		bool f[3] = {};
		ll cnt = 2;
		ll num = -1;
		for(int j = 0;j < 3;j++){
			if(field[i][j] == 0)continue;
			for(int k = 1; k < 3;k++){
				if(field[i][j+k] == 0)break;
				if(field[i][j] != field[i][j+k])break;
				if(k == 2){
					f[j] = 1;
					num = field[i][j];
				}
			}
			cnt += f[j];
		}
		if(num == -1)continue;
		res += num*cnt;
		for(int j = 0;j < 3;j++){
			if(!f[j])continue;
			for(int k = 0; k < 3;k++)field[i][j+k] = 0;
		}
	}
	return res;
}

void drop(){
	rep(j,5){
		vector<ll> v;
		rep(i,H){
			if(field[i][j] != 0)v.push_back(field[i][j]);
		}
		reverse(ALL(v));
		while(v.size()<H)v.push_back(0);
		reverse(ALL(v));
		rep(i,H)field[i][j] = v[i];
	}
}

void print(){
	for(int i = H - 1;i >= 0;i--){
		rep(j,5)cout << field[i][j] << " ";
		cout << endl;
	}
}

int main(){
	while(1){
		cin	>> H;
		if(H == 0)break;
		for(int i = 0 ;i < H;i++)for(int j = 0;j < 5;j++)cin >> field[i][j];
		int ans = 0;
		while(1){
			// print();
			int score = solve();
			// cout << score << endl;
			if(score == 0)break;
			ans += score;
			drop();
		}
		cout<<ans<<endl;
	}

}


Measured memory_bytes: 3148
d = int(input())
for _ in range(d):
    x, y, w, h = map(int, input().split())
    n = int(input())
    ans = 0
    for i in range(n):
        cx, cy = map(int, input().split())
        if x <= cx <= x + w and y <= cy <= y + h:
            ans += 1
    print(ans)

Measured memory_bytes: 6720
b[101][101];xg,yg;
r(x,y,c){if(c!=b[x][y])return 0;if(x==xg&&y==yg)return 1;b[x][y]=0;return r(x+1,y,c)||r(x,y+1,c)||r(x-1,y,c)||r(x,y-1,c)?1:0;}
main(xs,ys,n,c,d,x,y){
for(;scanf("%d%d",&x,&y),x;puts(b[xs][ys]&&b[xg][yg]&&b[xs][ys]==b[xg][yg]&&r(xs,ys,b[xs][ys])?"OK":"NG"))
for(scanf("%d%d%d%d%d",&xs,&ys,&xg,&yg,&n);n;n--)
if(scanf("%d%d%d%d",&c,&d,&x,&y),d)b[x][y]=b[x+1][y]=b[x][y+1]=b[x+1][y+1]=b[x][y+2]=b[x+1][y+2]=b[x][y+3]=b[x+1][y+3]=c;else b[x][y]=b[x+1][y]=b[x+2][y]=b[x+3][y]=b[x][y+1]=b[x+1][y+1]=b[x+2][y+1]=b[x+3][y+1]=c;
return 0;
}

Measured memory_bytes: 0
N,K=map(int,input().split())
ans=0.0
tmp=0
ex=0
for i in range(1,N+1):
  if i>=K:
    ans+=1/N
  else:
    tmp=i
    for a in  range(1,10**5):
      tmp*=2
      if tmp>=K:
        ex=a
        break
    ans+=(1/N)*(1/2)**ex
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 1000000007;

//

int main() {
	int n,memo=1000000;
	ll ans[500][500];
	cin >> n;
	for (int i = 0; i <= sqrt(n*2); i++) {
		if (i*(i + 1) == n*2) {
			memo = i;
			break;
		}
	}
	if (memo == 1000000) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	int count = 1;
	for (int i = 0; i < memo; i++) {
		for (int j = i; j < memo; j++) {
			ans[i][j] = count;
			ans[j+1][i] = count;
			count++;
		}
	}
	cout << memo + 1 << endl;
	for (int i = 0; i < memo+1; i++) {
		cout << memo<<' ';
		for (int j = 0; j < memo; j++) {
			cout << ans[i][j];
			if (j != memo - 1)cout << ' ';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main()
{
    int a, b, c, k;
    int dupla = 0;
    int sum = 0;
    scanf("%d %d %d %d",&a, &b, &c, &k);
    while(k != 0) {
        if(a >= b && a >= c) {
            dupla = 2*a;
            a = dupla;
        }
        else
            if(b >= c){
                dupla = 2*b;
                b = dupla;
                
            }
            else {
                dupla = 2*c;
                c = dupla;
            }
        k--;        
    }
    if(a >= b && a >= c)
        sum = dupla + b + c;
    else
        if(b >= c)
            sum = a + dupla + c;
        else
            sum = a + b + dupla;
            
    printf("%d\n", sum);

    return 0;
}

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

using str = string;
using ss = stringstream;

str a[60];

#define fi first
#define se second

#define DIRMAX 4
pair<int,int> dir[4]=
{
    { 0,-1},
    {-1, 0},
    { 1, 0},
    { 0, 1},
};

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

    int h,w;cin>>h>>w;

    ss maketop;
    for(int i=0;i<w+2;i++)maketop<<".";

    a[0]=maketop.str();
    a[h+1]=maketop.str();

    for(int i=0;i<h;i++)
    {
        str s;
        cin>>s;
        ss makemid;

        makemid<<"."<<s<<".";
        
        a[i+1]=makemid.str();
    }

    bool ans=true;

    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
    {
        if(a[i][j]=='#')
        {
            bool c=true;
            for(int k=0;k<DIRMAX;k++)
            if(a[i+dir[k].fi][j+dir[k].se]=='#')
            {
                c=false;
                break;
            }

            if(c)
            {
                ans=false;
                break;
            }
        }
    }

    puts(ans?"Yes":"No");

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int cnt[3] = {0, 0, 0};
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    int j;
    for (j = 0; j < 3; ++j) {
      if (a % 2) break;
      a /= 2;
    }
    ++cnt[min(2, j)];
  }
  cout << ((cnt[0] <= cnt[2]) || (cnt[0]-1 <= cnt[2] && !cnt[1]) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using graph = vector<vector<int>>;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    ll n,m;
    cin >> n >> m;
    if(n == 1 || m == 1) cout << abs(max<ll>(n,m) - 2) << endl;
    else cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
n= int(input())
f=[[int(x) for x in input().split()] for _ in range(n)]
p=[[int(x) for x in input().split()] for _ in range(n)]

ans = -1*10**9
for i in range(1,2**10):
    ls = []
    for j in range(10):
        if (i>>j)&1:
            ls.append(1)
        else:
            ls.append(0)
    cnt = []
    for k in range(n):
        cn = 0
        for l in range(10):
            if ls[l]==f[k][l]==1:
                cn+=1
            else:
                pass
        cnt.append(cn)
    can =0    
    for m in range(n):
        can += p[m][cnt[m]]
    
    ans = max(ans,can)

print(ans)

Measured memory_bytes: 43628
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }
    int count = 0;
    ll state = h[0];
    int mn = 0;
    for(int i = 1; i < n; i++){
        if(state >= h[i]){
            count++;
            state = h[i];
            mn = max(mn, count);
        }
        else{
            count = 0;
            state = h[i];
        }
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
using namespace std;
using ll = long long;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;
}


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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"NO"<<endl;exit(0);}
long long a,b,c,d;
const long long N=1000000007;

long long n;
long long arr[4];
long long arr2[2][4];
int main(){
	
	string s;
	cin>>s;
	int lnth=s.length();
	if(s[lnth-1]=='s')s+="es";
	else s+="s";
	cout<<s<<endl;
	return 0;
			
}

Measured memory_bytes: 3640
using System;

namespace abc104_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int rate=int.Parse(Console.ReadLine());
            if (rate < 1200)
            {
                Console.WriteLine("ABC");
            }else if (rate < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }
    }
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }else if(A >= 6){
        cout << B / 2 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 892
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int k=ir.nextInt();
		int s=ir.nextInt();
		int ret=0;
		for(int i=0;i<=k;i++){
			for(int j=0;j<=k;j++){
				if(s>=i+j&&s<=i+j+k)
					ret++;
			}
		}
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
struct UFT{
  vector<int> par;//親
  vector<int> rank;//木の深さ
  vector<int> size;//木の大きさ
  int n;
  
  UFT(int _n)
  {
    n = _n;
    par.resize(n);
    rank.assign(n,0);
    size.assign(n,1);
    rep(i,n){
      par[i] = i;
    }
  }
  
  //xの根を返す
  int find(int x)
  {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  //x,yを併合
  void unite(int x,int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }
    else{
      par[y] = x;
      size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じグループにいるかどうかを返す
  bool same(int x,int y)
  {
    return find(x) == find(y);
  }

  //xの属する木のサイズを探す
  int usize(int x)
  {
    return size[find(x)];
  }
};

int main()
{
  int n,m,k;cin >> n >> m >> k;
  UFT uf(n);
  vector<int> f(n,0),b(n,0);
  rep(i,m){
    int x,y;cin >> x >> y;x--;y--;
    f[x]++;f[y]++;
    uf.unite(x,y);
  }
  rep(i,k){
    int x,y;cin >> x >> y;x--;y--;
    if(uf.same(x,y)){    b[x]++;b[y]++;}
  }
  rep(i,n){
    int res=uf.usize(i)-f[i]-b[i]-1;
    //    cout << i << ":" << uf.usize(i) << ":" << f[i] << ":" << b[i] << "\n";
    cout << res << " ";
  }
  cout  << "\n";
  
    
  return 0;
}


Measured memory_bytes: 2816
N, K = map(int, input().split())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7

pos = sorted(v for v in X if v >= 0)
neg = sorted(-v for v in X if v < 0)

ok = False  # True: ans>=0, False: ans<0
if pos:
    if N == K:
        # Select all -> number of negatives must be even
        ok = len(neg) % 2 == 0
    else:
        ok = True
else:
    # All negative and even number is selected
    ok = K % 2 == 0

ans = 1
if ok:
    # ans >= 0
    if K % 2 == 1:
        ans = ans * pos.pop() % MOD

    # 答えは正になる→二つの数の積は必ず正になる．
    cand = []
    while len(pos) >= 2:
        x = pos.pop() * pos.pop()
        cand.append(x)

    while len(neg) >= 2:
        x = neg.pop() * neg.pop()
        cand.append(x)

    cand.sort(reverse=True)
    for i in range(K // 2):
        ans = ans * cand[i] % MOD
else:
    # ans <= 0
    cand = sorted(X, key=lambda x: abs(x))
    for i in range(K):
        ans = ans * cand[i] % MOD

print(ans)


Measured memory_bytes: 114468
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, k, cnt = 0;
    string s;
    cin >> n >> k >> s;
    for (int i = 0; i + 1 < n; ++i) {
        if (s[i] == s[i + 1])
            cnt++;
    }
    cout << min(n - 1, cnt + 2 * k) << endl;

    return 0;
}

Measured memory_bytes: 512
def check(a, b):
    return pow(a,5) - pow(b,5)

n = int(input())
a = 0
for i in range(0,120):
    for j in range(-119,i):
      if a == 0:
        if n == check(i,j):
          print(i,j)
          a = 1
          

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

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

    if(n%2==0){
        ll left = a[n/2-1]+a[n/2];
        ll right =  b[n/2-1]+b[n/2];
        cout << right-left+1 << endl;
        return 0;
    }else{
        ll left = a[n/2];
        ll right =  b[n/2];
        cout << right-left+1 << endl;
        return 0;
    }
}

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

const int maxn=1e3+10;
const int mod=1000000000+7;
const double eps=1e-6;

int n,m,k,ans;
char a[20][maxn];
int s[20][maxn];
bool v[20];

void dfs(int cnt,int res) {
    if(cnt==n) {
        int ex=res;
        int b[30];
        for(int i=0;i<=n;i++)
            b[i]=0;
        vector<int>g;
        for(int i=1;i<=n;i++) {
            if(v[i]) {
                g.push_back(i);
            }
        }
        g.push_back(n);
        int len=g.size();
        for(int i=1;i<m;i++) {
            for(int j=0;j<len;j++) {
                if(j==0) b[j]+=s[g[j]][i];
                else b[j]+=s[g[j]][i]-s[g[j-1]][i];
                if(b[j]>k) return ;
            }
            for(int j=0;j<len;j++) {
                if(j==0) {
                    if(b[j]+s[g[j]][i+1]>k) {
                        res++;
                        for(int k=0;k<len;k++) {
                            b[k]=0;
                        }
                        break;
                    }
                } else if(b[j]+s[g[j]][i+1]-s[g[j-1]][i+1]>k) {
                    res++;
                    for(int k=0;k<len;k++) {
                        b[k]=0;
                    }
                    break;
                }
            }
        }
       // if(ex==0) cout<<res<<endl;
        ans=min(ans,res);
        return ;

    }
    v[cnt]=0;
    dfs(cnt+1,res);
    v[cnt]=1;
    dfs(cnt+1,res+1);
}
int main() {
   // freopen("test.txt","r",stdin);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            s[i][j]=(a[i][j]=='1')+s[i-1][j];
        }
    }
    ans=n-1+m-1;
    dfs(1,0);
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
use std::io;

fn input() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).unwrap();
    inp = inp.trim().to_string();
    inp
}

fn main() {
    let inp = input();
    if inp == "RRR" {
        println!("3");
    }
    else if inp.find("RR") != None {
        println!("2");
    }
    else if inp.find("R") != None {
        println!("1");
    }
    else {
        println!("0");
    }
}

Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int l, r, d;
    cin  >> l >> r >> d;
    int ans = r /d;
    ans -= (l - 1) / d;
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <stdio.h>

int main(void) {
int input[3];
int i, r, temp;

scanf("%d %d %d", &input[0], &input[1], &input[2]);
for(i = 0; i < 3; i++) {
for(r = i; r < 3; r++) {
if (input[i] > input[r]) {
temp = input[i];
input[i] = input[r];
input[r] = temp;
}
}
}

printf("%d %d %d\n", input[0], input[1], input[2]);

return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int k;
	cin >> k;
	int x = 7 % k;
	int i = 1;
	for (int i = 1; i <= k; i++)
	{
		if (x == 0)
		{
			cout << i << endl;
			return;
		}
		x = (x * 10 + 7) % k;
	}
	cout << -1 << endl;
}

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

	solve();
}


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

constexpr char nl{'\n'};

int main()
{
	int N;
  cin >> N;
  long long height[N], currentMax{}, sumOfStools{};

  for(int i{} ; i<N; ++i){
    cin >> height[i];
  }

  currentMax = height[0];
  for(int i{1} ; i<N ; ++i){
    if(height[i] < currentMax){
      sumOfStools += currentMax - height[i];
    }
    else if(height[i] > currentMax){
      currentMax = height[i];
    }
  }
  
  cout << sumOfStools;

}

Measured memory_bytes: 5192
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    string ans = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') ans += "0";
        if(s[i] == '1') ans += "1";
        if(s[i] == 'B' && ans.size() != 0) ans = ans.substr(0, ans.size()-1);
    }
    cout << ans << endl;    
    return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    int x;
    cin>>x;

    if(x >= 30){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

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

int n, m;
vector<int> adj[100005];

int visited[100005], memo[100005];
int f(int x){
    if(visited[x]) return memo[x];
    visited[x] = 1;

    int ret = 0;
    for(int a: adj[x]) ret = max(ret, f(a) + 1);
    return memo[x] = ret;
}

int main(){
    scanf("%d %d", &n, &m);
    for(int i = 1, s, e; i <= m; i++){
        scanf("%d %d", &s, &e);
        adj[s].push_back(e);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, f(i));
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 8576
n = int(input())
v = list(map(int, input().split()))
v_even = v[0::2]
v_odd = v[1::2]

even_dict = {}
odd_dict = {}

for i in range(n//2):
	tmp = v_even[i]
	if tmp not in even_dict:
		even_dict[tmp] = 1
	else:
		even_dict[tmp] += 1
	tmp = v_odd[i]
	if tmp not in odd_dict:
		odd_dict[tmp] = 1
	else:
		odd_dict[tmp] += 1

odd_items = sorted(odd_dict.items(), key=lambda x:x[1], reverse=True)
even_items = sorted(even_dict.items(), key=lambda x:x[1], reverse=True)
odd_items.append((0,0))
even_items.append((0,0))

if odd_items[0][0] != even_items[0][0]:
	print(n-odd_items[0][1]-even_items[0][1])
else:
	print(min(n-odd_items[0][1]-even_items[1][1], n-odd_items[1][1]-even_items[0][1]))



Measured memory_bytes: 21628
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n <- readInt
  a <- readIntLists n
  print $ length $ filter (\x -> odd $ length x) $ group $ sort a


Measured memory_bytes: 37244
def init(seg,init_val,n,num):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=min(seg[2*i+1],seg[2*i+2]) 
    return seg
    
def query(seg,p,q,n,num):
    if q<=p:
        return float("inf")
    p += num-1
    q += num-2
    res=float("inf")
    while q-p>1:
        if p&1 == 0:
            res = min(res,seg[p])
        if q&1 == 1:
            res = min(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = min(res,seg[p])
    else:
        res = min(min(res,seg[p]),seg[q])
    return res

def init2(seg,init_val,n,num):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i] = max(seg[2*i+1],seg[2*i+2]) 
    return seg
    
def query2(seg,p,q,n,num):
    ide_ele = -float("inf")
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg[p])
        if q&1 == 1:
            res = max(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg[p])
    else:
        res = max(max(res,seg[p]),seg[q])
    return res


def main():
    import sys
    input = sys.stdin.readline
    N,K = map(int,input().split())
    P = list(map(int,input().split()))
    
    num =2**(N-1).bit_length()
    seg1=[float("inf")]*2*num
    seg1 = init(seg1,P,N,num)
    seg2=[-float("inf")]*2*num
    seg2 = init2(seg2,P,N,num)
    
    ans = 1
    c = 0
    tmp = 0
    for i in range(N-1):
        if P[i]<P[i+1]:
            tmp += 1
        else:
            if tmp >= K-1:
                c += 1
            tmp = 0
    if tmp >= K-1:
        c += 1
        tmp = 0
        
        
    for i in range(N-K):
        m = query(seg1, i, i+K+1,N,num)
        M = query2(seg2, i, i+K+1,N,num)
        if P[i]!=m or P[i+K]!=M:
            ans += 1
    
    print(ans- max(0,c-1))
        
    
    
main()

Measured memory_bytes: 126408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, Nsq, d_final = 10000000000000;
  cin >> N;
  Nsq = sqrt(N);
  cerr << Nsq << endl;
  
  if (Nsq < 2) {
    cout << N - 1 << endl;
  }
  else {
    for (int i = 1; i < Nsq + 1 ; i++) {
      ll Ntmp = N;
      if (N % i == 0) {
        d_final = min(d_final, i + N / i);
      }
    }
    cout << d_final - 2 << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

ll n, k;

ll fun(ll n, ll x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	ll p = (1LL << n) - 1;
	if (x <= 2*p)return fun(n - 1, x - 1);
	return p + 1 + fun(n - 1, x - 1 - 2*p);
}

int main(){
	cin >> n >> k;
	cout << fun(n, k) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,j,x,sum=0,sum2=0,mul=1,maxi = INT_MIN;
   vector<ll>vi,vt;
   cin>>n;
   for(i = 0 ;i<n-1 ;i++)
   {
       cin>>x;
       vi.push_back(x);
   }
   vt.push_back(vi[0]);
   for(i =  0 ;i<n-2 ;i++)
   {
       vt.push_back(min(vi[i],vi[i+1]));
   }
   vt.push_back(vi[n-2]);
   for(i = 0 ;i<n ;i++)
   {
       sum+=vt[i];
   }

   cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
  int N;
  cin >> N;
  vector<string> ans;
  
  auto dfs = [&](auto&& dfs_, string S, char m) -> void {
    if(S.size() == N) {
      ans.emplace_back(S);
      return;
    }
    
    for(char c = 'a'; c <= m; c++){
      dfs_(dfs_, S + c, (c == m ? m+1 : m));
    }
    return;
  };
  
  dfs(dfs, "", 'a');
  for(auto& c : ans){
    cout << c << endl;
  }
}


Measured memory_bytes: 7796
#include <stdio.h>
int main(void){
	int x, y = 1;
	x = 1;
	y = 1;
	while (x + y != 0){
		scanf("%d %d", &x, &y);
		if (x < y)printf("%d %d\n", x, y);
		else if (x > y) printf("%d %d\n", y, x);
		else if (x == y && x != 0) printf("%d %d\n", x, y);
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    ll N, D; cin >> N >> D;
    vector<int> W(N);
    vector<int> V(N);
    int w1 = 0;
    for(int i=0; i<N; i++){
        cin >> W[i] >> V[i];
        if(i==0) w1 = W[0];
        W[i] -= w1;
    }
    
    vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(N+1, vector<int>(401)));
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++){
            for(int k=0; k<401; k++){
                if(k-W[i] >= 0) dp[i+1][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-W[i]] + V[i]);
                else dp[i+1][j+1][k] = dp[i][j+1][k];
            }
        }
    }
    
    int ans = 0;
    for(int j=0; j<=N; j++){
        for(int k=0; k<401; k++){
            if(k + (ll)w1 * j <= D) ans = max(dp[N][j][k] , ans);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 16768
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

auto readNum(T)(){
  return readln.chomp.to!T;
}

auto readNums(T)(){
  return readln.chomp.split.to!(T[]);
}

void main(){
  auto r = readNums!long;

  foreach(i; 0 .. 10){
    r[2] = r[0] * r[2] - r[1];
    writeln(r[2]);
  }
}

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> costs(n, 0);
    vector<vector<int>> a(n, vector<int>(m, 0));

    rep(i, n)
    {
        cin >> costs[i];
        rep(j, m) cin >> a[i][j];
    }

    int min_cost = 1 << 29;
    bool all_flag = false;
    for (int i = 0; i < 1 << n; i++)
    {
        int cost = 0;
        vector<int> status(m, 0);
        rep(j, n)
        {
            if (i >> j & 1)
            {
                cost += costs[j];
                rep(k, m) status[k] += a[j][k];
            }
        }
        bool flag = true;
        rep(j, m) flag &= (status[j] >= x);
        if (flag)
        {
            all_flag = true;
            min_cost = min(min_cost, cost);
        }
    }
    cout << (all_flag ? min_cost : -1) << endl;
    return 0;
}


Measured memory_bytes: 3636
import scala.util.control.Breaks
object Main extends App {
  val bs = Breaks

  bs.breakable {
    for (line <- io.Source.stdin.getLines()) {
      if (line.isEmpty) bs.break()

      val Seq(a, b, c, d, e, f) = line.split(' ').map(_.toDouble).toList

      val det = a * e - b * d

      var x = "%.3f".format((c*e - b*f) / det)
      var y = "%.3f".format((a*f - c*d) / det)

      if (x == "-0.000") x = "0.000"
      if (y == "-0.000") y = "0.000"

      println("%s %s".format(x, y))
    }
  }
}


Measured memory_bytes: 44400
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
double a[100];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    double sum=0;
    rep(i,0,N){
        cin>>a[i];
        sum+=a[i];
    }
    double m=abs(sum-a[0]*N);
    int ans=0;
    rep(i,1,N){
        if(abs(sum-a[i]*N)<m){
            m=abs(sum-a[i]*N);
            ans=i;
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
from collections import Counter


n = int(input())
v = list(map(int, input().split()))
v_former = sorted([(v, k) for k, v in Counter(v[::2]).items()], reverse=True)
v_latter = sorted([(v, k) for k, v in Counter(v[1::2]).items()], reverse=True)
if len(v_former) == 1 and len(v_latter) == 1:
    if v_former[0][1] != v_latter[0][1]:
        print(0)
    else:
        print(n // 2)
elif v_former[0][1] != v_latter[0][1]:
    print(n - v_former[0][0] - v_latter[0][0])
elif len(v_former) == 1:
    print(n - v_former[0][0] - v_latter[1][0])
elif len(v_latter) == 1:
    print(n - v_former[1][0] - v_latter[0][0])
else:
    print(n - max(v_former[0][0] + v_latter[1][0], v_former[1][0] + v_latter[0][0]))


Measured memory_bytes: 20700
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int n;
string s;
int solve(char c,int mid)
{
    int r1=0,g1=0,b1=0;
    int r2=0,g2=0,b2=0;
    for(int i=0;i<mid;i++)
    {
       if(s[i]=='R')r1++;
       else if(s[i]=='G')g1++;
       else if(s[i]=='B')b1++;
    }
    for(int i=mid+1;i<n;i++)
    {
         if(s[i]=='R')r2++;
       else if(s[i]=='G')g2++;
       else if(s[i]=='B')b2++;
    }
    int ret=0;
    if(c=='R')
    {
        ret=g1*b2+g2*b1;

    }
    else if(c=='G')
    {
         ret=r1*b2+r2*b1;
    }
    else if(c=='B')
    {
          ret=g1*r2+g2*r1;
    }
     for(int i=mid-1,j=mid+1;i>=0 && j<n ;i--,j++)
        {
            if(s[i]!=c && s[j]!=c)
            {
                if(s[i]!=s[j])ret--;
            }
        }
     return ret;
}
 main()

{
    fast
    cin>>n;
    cin>>s;
    int ses=0;
    f(i,1,n-2)
    {

       char ch=s[i];
       ses+=solve(ch,i);
    }
    cout<<ses<<endl;


















    return 0;

}













Measured memory_bytes: 3672
a, b , m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

min = min(al) + min(bl)
for i in range(m):
    x, y, c = map(int, input().split())
    onedan = al[x-1] + bl[y-1] - c
    if min > onedan:
        min = onedan

print(min)


Measured memory_bytes: 70764
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int k,n;
    cin>>k>>n;
    vector<int>a(n),b;
    int ans=0;
    rep(i,n)cin>>a[i];
    for(int i=1; i<n; ++i){
        b.push_back(a[i]-a[i-1]);
    }
    b.push_back(a[0]-a[n-1]+k);
    sort(b.rbegin(),b.rend());
    rep(i,b.size())ans+=b[i];
    ans-=b[0];
    cout<<ans<<endl;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001;
const int mod = 1e9 + 7;

char mat[maxn][maxn];
int dp[maxn][maxn];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int h, w;
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; ++i)
        scanf("%s", mat[i] + 1);
    dp[0][1] = 1;
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            if (mat[i][j] == '.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
    printf("%d\n", dp[h][w]);
}

Measured memory_bytes: 5120
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		String S = "";

		for(int i=0;i<K;i++) {
			S += "ACL";
		}
		System.out.println(S);

	}
}

Measured memory_bytes: 38596
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl

#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

const int INF=1<<28;
int main(){
	while(true){
		loop:
		int q1;cin >> q1;
		if(q1==0)break;
		int b,c1,c2,q2;cin >> b >> c1 >> c2 >> q2;

		for(int res1=q2;res1>=1;res1--){
			if(b-res1*c1<0)continue;
			int res2=(b-res1*c1)/c2;
			if(res1+res2>=q1){
				cout << res1 << " "<< res2 <<endl;
				goto loop;
			}
		}
		cout <<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
	double PI = 3.14159265358979;
	Scanner in= new Scanner(System.in);
	double r = in.nextDouble();
	double s = PI * r * r;
	double len = 2 * PI *r;

	System.out.printf("%f %f", s, len);
    }   
}

Measured memory_bytes: 18920
#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 all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
int main(){
    int n,mmm=0;
    cin>>n;
    map<string, int> m;
    string s;
    REP(i,n){
        cin>>s;
        m[s]++;
        mmm=max(m[s],mmm);
    }
    for(auto i:m){
        if(i.second==mmm) cout<<i.first<<endl;
    }
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i=a;i<=b;++i){
        if(c%i == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int m = max(a - b, a + b);
	m = max(m, a*b);
	cout << m;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] flowers = new int[N];
    for(int i = 0; i < N; i++) {
      flowers[i] = sc.nextInt();
    }

    Main abc116C = new Main();
    System.out.println(abc116C.solve(flowers));
  }

  public int solve(int[] flowers) {
    int ans = flowers[0];
    for(int i = 1; i < flowers.length; i++ ){
      int delta = flowers[i] - flowers[i-1];
      if(delta > 0) ans += delta;
    }
    return ans;
  }
}


Measured memory_bytes: 23636
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

#  典型経路探索なのでDP、進研ゼミで習った

dp = [[0] * N for _ in range(2)]

for i in range(2):
    for j in range(N):
        if i == 0 and j == 0:
            dp[i][j] = A[0][0]

        elif i == 0:
            dp[i][j] = dp[i][j - 1] + A[i][j]

        elif j == 0:
            dp[i][j] = dp[i - 1][j] + A[i][j]
            
        else:
            dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + A[i][j]
            
print(dp[1][N - 1])

Measured memory_bytes: 9224
from collections import deque

n,m=map(int,input().split())
graph=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)#aにはbがつながってる
    graph[b-1].append(a-1)#bにはaがつながってる
#print(graph)

res=[-1]*n
que=deque()
que.append(0)

while len(que)>0:
    i=que.popleft();
    for j in graph[i]:
        if res[j]==-1:
            res[j]=i
            que.append(j)
    #print(que)

print("Yes")
for l in res[1:]:
    print(l+1)

Measured memory_bytes: 94400