akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
	
		//for(int i=0;i<N;i++) {}
		
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		if(A<0||A>9||B<0||B>9) {
			p(-1);
		}else p(A*B);
		
	}
		
		
		
		static long Nb(long t) {
			long r=1;
			for(long i=t;i>0;i--) {
				r*=i;
				r%=mod;
				
			}
			return (int)r;
			
		}
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


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

int main(){
  long long X, year, money;
  cin >> X;
  money = 100;
  year = 0;
  while(money < X){
    year++;
    money += (money / 100);
  }
  cout << year << endl;
}

Measured memory_bytes: 3588
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)


int main(){ FastIO;

int a,b,c;cin>>a>>b>>c;
cout<<min(c,b/a);

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int dist(tuple<int, int ,int> tps, tuple<int, int, int> tpc) {
  int x1 = get<1>(tps);
  int x2 = get<1>(tpc);
  int y1 = get<2>(tps);
  int y2 = get<2>(tpc);
  return abs(x1 - x2) + abs(y1 - y2);
}

int f(tuple<int ,int ,int> tps, vector<tuple<int, int, int>> tpc) {
  int tmp = 1000000000;
  int n = tpc.size();
  int res;
  rep(i, n) {
    int t = dist(tps, tpc[i]);
    if(tmp > t) {
      tmp = t;
      res = get<0>(tpc[i]);
    }
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int ,int>> tps(n);
  vector<tuple<int, int, int>> tpc(m);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    tps[i] = make_tuple(i+1, a, b);
  }
  rep(i, m) {
    int c, d;
    cin >> c >> d;
    tpc[i] = make_tuple(i+1, c, d);
  }


  rep(i, n) {
    cout << f(tps[i],tpc) << endl;;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)

const int    INF = 1e11;
const double EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }

using namespace std;

inline void Main() {
	int n, k; cin >> n >> k;
	double ret = 0;
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;
		int now = i;
		while (now < k) {
			now *= 2;
			tmp /= 2;
		}
		ret += tmp;
	}
	printf("%.12f\n", ret);
}

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

	Main();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
N,M = [int(x) for x in input().split(' ')]
MLIS = [0] * M
for i in range(N):
  p = [int(x) for x in input().split(' ')]
  for j in range(1,p[0]+1):
    #print(p[j])
    MLIS[p[j]-1] += 1
    
    
cnt = 0
for i in range(M):
  #print(i,MLIS[i])
  if MLIS[i] == N:
    cnt +=1
print(cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>

const int MAXN = 1e5 + 5;

int n, m, u, v, s, t;
int dp[MAXN][3];

struct node {
    int nv, flag;
    node(int vv = 0, int ff = 0) {
        nv = vv;
        flag = ff;
    }
};

std::vector<int> con[MAXN];
std::queue<node> q;

void ins(int start, int end) {
    con[start].push_back(end);
}

void bfs() {
    dp[s][0] = 0;
    q.push(node(s, 0));
    while (!q.empty()) {
        int nv = q.front().nv, nf = q.front().flag;
        for (int i = 0; i < con[nv].size(); ++i) {
            int tv = con[nv][i];
            if (dp[tv][(nf + 1) % 3] == -1) {
                dp[tv][(nf + 1) % 3] = dp[nv][nf] + 1;
                q.push(node(tv, (nf + 1) % 3));
            }
        }
        q.pop();
    }
}

int main() {
    scanf("%d%d", &n, &m);
    while (m--) {
        scanf("%d%d", &u, &v);
        ins(u, v);
    }
    scanf("%d%d", &s, &t);
    memset(dp, -1, sizeof(dp));
    bfs();
    if (dp[t][0] == -1)
        printf("-1");
    else 
        printf("%d", dp[t][0] / 3);
    return 0;
}

Measured memory_bytes: 7040
#include <stdio.h>


int main(int argc, char const *argv[]) {

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

  int flag = 0;
  for (int i=1; i <= 9; i++){
      for (int j=1; j <= 9; j++){
          if (i*j == n){
              flag = 1;
          }
      }
  }

  if (flag == 0){
      printf("No\n");
  }
  else {
      printf("Yes\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back
#define mp make_pair

#define all(x) x.begin(), x.end()

#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

const ll INF = int(1e9) + 123;
const int UNF = int(1e5) * 2;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

map <int, pair <int, int> > x;
vector <int> ans;

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m, d;
	cin >> n >> m >> d;
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < m; j ++) {
			int o;
			cin >> o;
			x[o].F = i + 1;
			x[o].S = j + 1;
		}
	}
	int dp[n * m + 1];
	for(int i = 1; i <= n * m; i ++) {
		if(i - d <= 0) {
			dp[i] = 0;
		}
		else {
			dp[i] = dp[i - d] + abs(x[i].F - x[i - d].F) + abs(x[i].S - x[i - d].S);
		}
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i ++) {
		int l, r;
		cin >> l >> r;
		ans.pb(dp[r] - dp[l]);
	}
	for(int i = 0; i < ans.size(); i ++) {
		cout << ans[i] << endl;
	}
	exit(0);
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int r[n] = {0}, a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        r[a-1]++;
        r[b-1]++;
    }
    for (int i = 0; i < n; ++i)
        cout << r[i] << endl;
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  string S; cin >> S;

  ll cnt = 0;
  for (ll i = 1; i < N; i++) {
    if (S.at(i) == 'E') cnt++;
  }
  ll ans = cnt;
  for (ll i = 0; i+1 < N; i++) {
    if (S.at(i) == 'W') cnt++;
    if (S.at(i+1) == 'E') cnt--;
    ans = min(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3796
class Node():
    def __init__(self, id):
        self.id = id
        self.p = self
        self.rank = 0


class DisjointSet():
    def __init__(self, n):
        self.nodes = {}
        for i in range(n):
            self.makeSet(i)

    def makeSet(self, i):
        self.nodes[i] = Node(i)

    def findSet(self, x):
        if x.p is not x:
            x.p = self.findSet(x.p)
        return x.p

    def unite(self, x, y):
        # ランクの低い方を子にする
        px = self.findSet(x)
        py = self.findSet(y)
        if px.rank > py.rank:
            py.p = px
        else:
            px.p = py
        if x.rank == y.rank:
            py.rank += 1

    def bool(self, x, y):
        return self.findSet(x) == self.findSet(y)


n, q = map(int, input().split())
uf = DisjointSet(n)
for i in range(q):
    com, ix, iy = map(int, input().split())
    if com == 0:
        # unite
        uf.unite(uf.nodes[ix], uf.nodes[iy])
    else:
        # same
        print(1 if uf.bool(uf.nodes[ix], uf.nodes[iy]) else 0)



Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i, a, b) for (int i = a; i <= (int)b; ++i)
#define lp2(i, a, b) for (int i = a; i >= b; --i)
#define f(x) return cout << x << "\n", 0
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define p(x) cout << #x << " = { " << x << " } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define clr(c, x) memset(c, x, sizeof(c));
using namespace std;
const int N = 2e5 + 5, mod = (int)1e9 + 7;
set<pii> in, exist;
int main()
{
    ll n, m;
    int z;
    cin >> n >> m >> z;
    while (z--)
    {
        pii p;
        cin >> p.F >> p.S;
        in.insert(p);
        lp(i, -2, 2) lp(j, -2, 2) if (p.F + i >= 1 && p.S + j >= 1 && p.F + i <= n && p.S + j <= m)
            exist.insert({p.F + i, p.S + j});
    }
    int sum[10] = {};
    ll tot = 0;
    for (auto u : exist)
    {
        int cnt = 0;
        lp(i, 0, 2) lp(j, 0, 2)
        {
            if (u.F + i >= 1 && u.S + j >= 1 && u.F + i <= n && u.S + j <= m)
                cnt += in.count({u.F + i, u.S + j});
            else
            {
                cnt = 0;
                break;
            }
        }
        if (cnt)
        { 
            ++sum[cnt];
            ++tot;
        }
    }
    tot = ((n - 2) * (m - 2)) - tot;
    cout << tot << "\n";
    lp(i, 1, 9) cout << sum[i] << "\n";
    return 0;
}

Measured memory_bytes: 122112
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,ans;
    cin>>a>>b;

    c=a+b;
    if(c%2==0){
        ans=c/2;
    }
    else{
        ans=c/2+1;
    }
    cout<<ans<<endl;
}


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

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int n, a, b;
    int max, min;
    int high, low;
    char str[1000], *t1, *t2, *t3;
    fgets(str, sizeof(str), stdin);
    t1 = strtok(str, " ");
    t2 = strtok(NULL, " ");
    t3 = strtok(NULL, " ");
    n = atoi(t1);
    a = atoi(t2);
    b = atoi(t3);
    
    if(a == b) {
        high = a;
        low = b;
    } else if(a > b) {
        high = a;
        low = b;
    } else {
        high = b;
        low = a;
    }
    
    max = low;
    min = low - (n - high);
    if(min < 0) min = 0;
    printf("%d %d", max, min);
    
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void)
{
    int n,y;
    cin >> n >> y;
    y/=1000;
    for(int i=0;i<=2000;i++)
    {
        for(int j=0;j<=4000;j++)
        {
            if(10*i+5*j+(n-i-j)==y && n-i-j>=0)
            {
                cout << i << ' ' << j << ' ' << n-i-j;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
    return 0;
}


Measured memory_bytes: 256
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val S = sc.next().toCharArray()
        pw.println(S.count { it == '+'} - S.count { it == '-'})
    }
}


Measured memory_bytes: 31124
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,l,i,min=1000,sum=0;
    scanf("%d %d",&n,&l);
    for(i=1;i<=n;i++){
        sum+=l+i-1;
        if(abs(l+i-1)<abs(min)){
            min=l+i-1;
        }
    }
    sum-=min;
    printf("%d",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
int main(void){
    int n, q;
    cin >> n >> q;
    
    int in[100010], num[100010];
    for (int i = 0; i < n; i++) num[i] = i;
    fill(in, in + n, 0);
    in[0] = 2;
    in[1] = 1;
    
    int aim = 0;
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        //cout << num[a] << " " << num[b] << endl;
        
        if (in[a] == 2) {
            aim = b;
            in[a] = in[b];
            in[b] = 2;
        }
        else if (in[b] == 2) {
            aim = a;
            in[b] = in[a];
            in[a] = 2;
        }
        else {
            int ktmp = in[b];
            in[b] = in[a];
            in[a] = ktmp;
        }
        if (aim != 0) in[aim - 1] = 1;
        if (aim != n - 1) in[aim + 1] = 1;
        
        int tmp = num[b];
        num[b] = num[a];  num[a] = tmp;
        /*
        for (int i = 0; i < n; i++) {
            cout << in[i] << " ";
        }
        cout << endl;*/
    }
    
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (in[i] > 0) ans++;
        //cout << in[i] << " ";
    }
    /*cout << endl;
    for (int i = 0; i < n; i++) {
        cout << num[i] << " ";
    }
    cout << endl;
    */
    cout << ans << endl;
    
}


Measured memory_bytes: 640
x = input()
a = x[0]
b = x[1]
c = x[2]
d = x[3]

op = ["+", "-"]
for i in op:
    for j in op:
        for k in op:
            cal = a + i + b + j + c + k + d
            if eval(cal) == 7:
                ans = cal + "=7"

print(ans)


Measured memory_bytes: 3060
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if b[i] >= a[i]:
       ans += a[i]
       b[i] -= a[i]
       a[i] = 0
       if b[i] >= a[i+1]:
           ans += a[i+1]
           a[i+1] = 0
       else:
           ans += b[i]
           a[i+1] -= b[i]

    else:
        ans += b[i]

print(ans)

Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll f(ll x) {
    int bit;
    if (((x+1) / 2) % 2 == 1) {
        bit = 1;
    } else { 
        bit = 0;
    }

    if ( x%2 == 0 ) return bit ^ x;
    else return bit;
}


int main() {
    ll A, B;
    cin >> A >> B;
    ll ans = f(A-1) ^ f(B);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  string S;

  cin >> S;

  for(int i=0;i<S.length();i++){
    printf("x");
  }
  putchar('\n');

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

struct data{
	int t,n,m,s;
}d[1001];
struct QUESTION{
	int s,e,m;//* start,end,m
}q[51];

int t[1261][10001];

int main(){
	int i,j,k,l,n,m,r,qq;
	int ans;
	while(scanf("%d%d",&n,&m),n+m){
		scanf("%d",&r);
		for(i = 0;i < r;i++)
			scanf("%d%d%d%d",&(d[i]).t,&(d[i]).n,&(d[i]).m,&d[i].s);
		scanf("%d",&qq);
		for(i = 0;i < qq;i++)
			scanf("%d%d%d",&q[i].s,&q[i].e,&q[i].m);

		for(i = 0;i < 1261;i++)
			for(j = 1;j <= m;j++)
				t[i][j] = 0;

		for(i = 0;i < r;i++){
			t[d[i].t][d[i].m] += (d[i].s - (d[i].s == 0));
		}

		for(j = 1;j <= m;j++){
			for(i = 1;i < 1261;i++){
				t[i][j] += t[i-1][j];
			}
		}

		for(i = 0;i < qq;i++){
			ans = 0;
			for(j = q[i].s;j < q[i].e;j++){
				if(t[j][q[i].m])ans++;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 49876
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans = 0;
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j+i<=n;++j)
        {
            if(i%r==0&&j%g==0&&(n-i-j)%b==0)
            {
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
/*
 * 2489.cc: Palindromic Number
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;

/* typedef */

typedef vector<int> vi;

/* global variables */

/* subroutines */

bool palindromic(int n) {
  vi ds;
  while (n) {
    ds.push_back(n % 10);
    n /= 10;
  }

  for (int i = 0, j = ds.size() - 1; i < j; i++, j--)
    if (ds[i] != ds[j]) return false;
  return true;
}

/* main */

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

  for (int d = 0;; d++) {
    int n0 = n - d, n1 = n + d;
    if (n0 >= 0 && palindromic(n0)) {
      printf("%d\n", n0);
      break;
    }
    if (n1 <= MAX_N && palindromic(n1)) {
      printf("%d\n", n1);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				var s = Console.ReadLine();
				for (int a = 0; a < 100; a++)
				{
					for (int b = 0; b < 26; b++)
					{
						var r = new string(s.Select(c => c == ' ' ? c : (char)((a * (c - 'a' + b) % 26) + 'a')).ToArray());
						if (r.Contains("that") || r.Contains("this"))
						{
							s = r;
						}
					}
				}
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 6728
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	scanf("%s", a);

	f(i, n) {
		if (a[i] == 'R')ans++;
		else ans--;
	}

	if(ans>0)printf("Yes\n");
	else printf("No\n");


	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

def main():
    N = int(input())
    T = input()
    S = []
    for s in T:
        if s == '(':
            S.append(1)
        else:
            S.append(-1)
    S = list(accumulate(S))
    # print(S)
    minS = min(S)
    if minS < 0:
        for i in range(N):
            S[i] -= minS
    print('('*max(0,-minS) + T + ')'*S[-1])

if __name__ == "__main__":
    main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int x,y;
	cin >> x >> y;
	int ans = 0;
	if (x < 4) {
		ans += 100000*(4-x);
	}
	if (y < 4) {
		ans += 100000*(4-y);
	}
	if (x == y and x == 1) {
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n), b(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	for (ll i = 0; i < n; i++) cin >> b[i];

	ll cnt_b = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] > b[i]) cnt_b += a[i] - b[i];
	}

	ll cnt_a = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] < b[i]) cnt_a += (b[i] - a[i]) / 2;
	}

	if (cnt_a >= cnt_b) Yes();
	else No();
}


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

d = [None] * n
sum = 0
for i in range(n):
    if i == n-1:
        d[n-1] = k - a[n-1] + a[0]
    else:
        d[i] = a[i+1] - a[i]
    sum += d[i]
ans = 2 * 10**11
for i in range(n):
    if sum - d[i] < ans:
        ans = sum - d[i]
print(ans)

Measured memory_bytes: 26444
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

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

void solve()
{
	int n;
	cin >> n;
	map<int,int> m;
	for(int i=2;i<=n;i++)
	{
		int x;
		cin >> x;
		//cout << x << " - ";
		m[x]++;
	}

	for(int i=1;i<=n;i++)
	{
		cout << m[i] << endl;
	}
}
int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
      //cout << "************" << endl;
      solve();
      //cout << "************"  << endl;
    }
		return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	vector<pii> e;
	int add[200005] = {};

	cin >> N;
	rep(i,N-1){
		int u, v;
		cin >> u >> v;
		u--; v--;
		if(u > v) swap(u, v);
		e.emplace_back(u, v);
		add[v]++;
	}

	sort(all(e));
	reverse(all(e));

	ll sum = 0, cur = 0;
	rep(i,N){
		cur += 1 - add[i];
		sum += cur;
	}
	ans += sum;
	rep(i,N){
		sum -= (N-i);
		while(!e.empty() && e.back().X == i){
			sum += N - e.back().Y;
			e.pop_back();
		}
		ans += sum;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6172
// AtCoderTemplate.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>

#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

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

void count1(ll a, int n, ll* count)
{
	a++;
	ll p = 1;
	rep(i, n)
	{
		ll d = a / p;
		ll r = a % p;

		if (d % 2 == 0)
		{
			//1がちょうど終わっている、もしくは0が途中で終わっている場合。
			//1は半分。切り捨て。
			count[i] = p * (ll)(d / 2);
		}
		else
		{
			//0がちょうど終わっている、もしくは1が途中で終わっている場合。
			//あまりがはみ出たの数。
			count[i] = p * (ll)(d / 2) + r;
		}

		p *= 2;
	}
}

int main()
{
	ll a, b;
	cin >> a >> b;
	
	int n = 1;
	ll p = 2;
	while (b >= p)
	{
		n++;
		p *= 2;
	}


	//a - 1のカウントを計算
	ll* counta = new ll[n]();
	count1(a - 1, n, counta);

	//bのカウントを計算
	ll* countb = new ll[n]();
	count1(b, n, countb);

	

	//計算
	ll ans = 0;
	for(int i = n -1;i >= 0;i--)
	{	
		ans = ans << 1;
		ans += (countb[i] - counta[i])%2;
	}

	cout << ans << endl;

}


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

using namespace std;

int main()
{
  int i, n, x, sum = 0, ans = 0;

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

  vector<int> a(n);

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

  sort(a.begin(), a.end());

  for (int i = 0; x > 0 && i < n; i++)
  {
    x -= a[i];
    ans++;
  }

  printf("%d", ans - 1 + (x == 0));
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, i, MAX, MIN = 0;
	long long sum = 0;
	//int x[1000000];
	scanf("%d", &n);
	int x[n];
	for(i = 0; i<n; i++){
		scanf("%d", &x[i]);
	}
	MAX = -10000000;
    MIN=10000000;
	for(i = 0; i<n; i++){
	    if(x[i]>MAX){
			MAX = x[i];
		}
		if(x[i]<MIN){
			MIN = x[i];
		}
		sum=sum+x[i];
		
	}
	printf("%d %d %lld\n", MIN, MAX, sum);
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int const MOD = int(1e9) + 7;

vector<string> grid;
vector<vector<int>> dp;
int main() {
    int h, w;
    cin >> h >> w;

    grid.resize(h);
    for (int i=0; i<h; ++i) cin >> grid[i];

    dp.resize(h, vector<int>(w,0));
    int p = 0;
    while (p<h && grid[p][0]=='.') dp[p++][0] = 1;

    p = 0;
    while (p<w && grid[0][p]=='.') dp[0][p++] = 1;

    for (int i=1; i<h; ++i) {
        for (int j=1; j<w; ++j) {
            if (grid[i][j]=='.') {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string X;
  cin >> X;
  vector<int> can (X.size(),0);
  int j = 0;
  for ( int i = 0 ; i < X.size() ; i++ ) {
    if ( X[i] == 'A' || X[i] == 'G' || X[i] == 'C' || X[i] == 'T' ) {
      can[j]++;
    }
    else {
      j++;
    }
  }
  sort (can.begin(),can.end());
  reverse (can.begin(),can.end());
  cout << can[0] << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(n<0) return 0;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    double a,b,c;
    cin>>a>>b>>c;
    double S,L,h,theta;
    theta=c*pi/180;
    S=a*b*sin(theta)/2.0;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(theta));
    h=2*S/a;
    printf("%lf\n",S);
    printf("%lf\n",L);
    printf("%lf\n",h);
    return 0;
}


Measured memory_bytes: 3420
//shan61916
#include <bits/stdc++.h>
	using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
	freopen("input.txt" , "r" , stdin);
#endif
	ll n ;
	cin>>n ;
	vector<ll> a(n+1) ;
	for(ll i=0;i<n;i++)cin>>a[i] ;
	vector<ll> dp(n+1) ;
	dp[0]=0 ;
	dp[1]=abs(a[1]-a[0]) ;
	for(ll i=2;i<n;i++)
	{
      ll x= abs(a[i]-a[i-1])+ dp[i-1] ;
      ll y= abs(a[i]-a[i-2])+dp[i-2] ;
      dp[i]=min(x,y) ;
	}
	cout<<dp[n-1] ;

 
	return 0;
}      // good night.

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

#define nax 100009
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> vi;

int main(){
	int n,k; cin>>n>>k;
	vi v(n);
	REP(i,n) cin>>v[i];

	bool dp[nax];
	dp[0] = false;//lose

	FOR(i,1,k+1){
		dp[i] = false;
		REP(j,n){
			if(i-v[j]<0) continue;
			if(!dp[i-v[j]]) dp[i] = 1;
		}
	}

	if(dp[k]) cout<<"First";
	else cout<<"Second";

	return 0;
}

Measured memory_bytes: 384
#include<cstdio>

int main(){
	int a, b, t; scanf("%d%d%d", &a, &b, &t);
	
	int ans=0;
	for(int cur = a;cur<=t;cur+=a)
		ans+=b;
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = SS()

    if sum([int(i) for i in list(N)]) % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 13456
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    string s,t; cin >> s >> t;
    ll ans = 10000000;

    rep(i,s.length()-t.length()+1){
        ll tmp = 0;
        rep(j,t.length()){
            if(t[j] != s[i+j]) tmp ++;
        }
        ans = min(ans,tmp);
    }
    cout << ans;

}


Measured memory_bytes: 3632
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, k = [int(s) for s in input().strip().split()]
    n %= k
    result = min(n, k - n)
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
// https://beta.atcoder.jp/contests/abc070

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

void print_yes_no(bool cond, string yes = "Yes", string no = "No") { cout << (cond ? yes : no) << endl; }

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = max(a, c), right  = min(b, d);
    int ans = max(right - left, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int n, ans = 0, k = 10, keta = 0;
    bool ok = true;
    cin >> n;
    repi(i,1, n+1){
        if (k / 10 == i) ok = true;
        if (i < k && ok) ans ++;
        else if ( i == k ){
            k *= 100;
            ok = false;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> A(3 * n);
    for(int i = 0; i < 3 * n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += A[3 * n - 2 - i * 2];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>

static constexpr int maxN = 30, 
                     maxM = 30;

bool liked[maxM][maxN];

int main() {
    int N, M;
    std::cin >> N >> M;

    for (int i = 0; i < N; i++) {
        int K;
        std::cin >> K;

        for (int j = 0; j < K; j++) {
            int A;
            std::cin >> A;

            A--;
            liked[A][i] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        bool all = true;
        for (int j = 0; j < N; j++) {
            all = all && liked[i][j];
        }
        if (all) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <cmath>



long long mod(long long  a, long long b)
{
    return a - (long long)(std::floor(double(a) / b)) * b;
}

long long power_func(long long a, long long b, long long p) {
    if (b == 0) return 1;
    if (b % 2 == 0){
        long long d = power_func(a, b / 2, p);
        return (d * d) % p;
    }
    //if (b % 2 == 1)
    return (a*power_func(a, b - 1, p)) % p;
}

class comb_calclator {
public:
    comb_calclator(int N, long long p):
        N(N),
        p(p),
        frac_N(N + 1, 0)
    {
        frac_N[0] = 1;
        for (int i = 1; i <= N; i++) {
            frac_N[i] = (frac_N[i - 1] * i) % p;
        }
    }
    
    long long comb(int n, int r) {
        if ((n < 0) || (r < 0) || (n < r)) return 0;
        if ((n == 0) || (r == 0)) return 1;
        long long a = frac_N[n];
        long long b = frac_N[r];
        long long c = frac_N[n - r];
        if (power_N.count(r) == 0)
            power_N[r] = power_func(b, p - 2, p);
        if (power_N.count(n - r) == 0)
            power_N[n - r] = power_func(c, p - 2, p);
        return (a * ((power_N[r] * power_N[n - r])  % p)) % p;
    }

private:
    int N;
    long long p;
    std::vector<long long> frac_N;
    std::map<int, long long> power_N;
};

int main()
{
    int n, N;
    std::cin >> n;
    N = n + 1;
    //std::vector<int> A;
    std::map<int, int> idx_map;
    int first_idx, second_idx;
    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        if (idx_map.count(a) == 0)
            idx_map[a] = i;
        else {
            first_idx = idx_map[a];
            second_idx = i;
        }
    }
    comb_calclator cc(N, 1000000007);
    int sub_N = N - second_idx + first_idx;
    for (int k = 1; k < N + 1; k++) {
        long long sub1 = 0;
        if (k <= sub_N) {
            sub1 = cc.comb(sub_N - 1, k - 1);
        }
        std::cout << mod((cc.comb(N, k) - sub1), 1000000007) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define modu 1000000007
using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)){
			cout << "DENIED";
			return 0;
		}
	}
	cout << "APPROVED";
	return 0;
}

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

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

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
    #ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,m;
    cin>>n>>m;
    vector<ii> v;
    for(int i=1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }
    sort(all(v));
    priority_queue<int,vi> Q;
    ll ans = 0;
    ll p = 0;
    for(int i=m-1;i>=0;i--){
        while(p < v.size() && v[p].first + i <= m){
            Q.push(v[p].second);
            p++;
        }

        if(!Q.empty()){
            ll val = Q.top();
            Q.pop();
            ans += val;
        }
    }

    cout << ans << "\n";
    return 0;   
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int main(){
string S; cin >> S;
int N=S.size();
for(int i=0; i<N; i++){
if(i%2){ if(S[i]=='R'){ cout << "No" << "\n"; return 0; } }
else{ if(S[i]=='L'){ cout << "No" << "\n"; return 0; } }
}
cout << "Yes" << "\n";
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  int l = 0, r = n-1;
  while(l < r){
    while(l < r && s[l] == 'R')l++;
    while(l < r && s[r] == 'W')r--;
    ans += l < r;
    l++;
    r--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3744