akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int s[510][510];
int main(){
    int n,m,q;cin>>n>>m>>q;
    int l,r;
    for (int i=0; i<m; ++i){
        cin>>l>>r;
        for (int j=r; j<=500; ++j)++s[l][j];//累積和は後にふつうに求めたほうがいいかもしれないです。今回はどちらでも余裕
    }
    int ans;
    for (int i=0; i<q; ++i){
        cin>>l>>r;
        ans=0;
        for (int j=l; j<=r; ++j)
            ans+=s[j][r]-s[j][l-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1e9 + 7;
int H, W, A, B;
ll inv[200010];
ll fac[200010], facInv[200010];

void init() {
  inv[1] = 1;
  for (int i = 2; i < 200010; i++) {
    inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
  }
  fac[0] = facInv[0] = 1;
  for (int i = 1; i < 200010; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    facInv[i] = facInv[i - 1] * inv[i] % MOD;
  }
}

ll comb(int n, int k) {
  if (!(k >= 0 && k <= n)) return 0;
  return fac[n] * facInv[k] % MOD * facInv[n - k] % MOD;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  cin >> H >> W >> A >> B;
  ll ans = comb(H + W - 2, H - 1);
  for (int i = 0; i < min(A, B); i++) {
    ans += (MOD - comb(H - A + B - 1, B - 1 - i) * comb(W - B + A - 1, A - 1 - i) % MOD) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        int N, M;
        N = cin.nextInt();
        M = cin.nextInt();
        int[] A = new int[M];
        int[] B = new int[M];
        for (int i = 0; i < M; i++)
        {
            A[i] = cin.nextInt() - 1;
            B[i] = cin.nextInt() - 1;
        }

        init(N);

        List<long> ans = new List<long>();
        long now = (long)N * (N - 1) / 2;
        ans.Add(now);

        for (int i = M - 1; i >= 1; i--)
        {
            long next = now;
            long add = (long)uni[root(A[i])] * uni[root(B[i])];
            if(connect(A[i], B[i]))
            {
                next -= add;
            }

            ans.Add(next);
            now = next;
        }

        ans.Reverse();
        for (int i = 0; i < M; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }

    int[] uni;
    void init(int N)
    {
        uni = new int[N];
        for (int i = 0; i < N; i++)
        {
            uni[i] = -1;
        }
    }

    int root(int a)
    {
        if (uni[a] < 0) return a;
        else return uni[a] = root(uni[a]);
    }

    bool connect(int a, int b)
    {
        a = root(a);
        b = root(b);
        if (a == b) return false;
        if (uni[a] > uni[b]) swap(ref a, ref b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }  

}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 19144
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int ans = 1000, cnt;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i <= s.length() - t.length(); i++) {
    cnt = 0;
    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) {
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}
function Main(input) {
  input = myconv(input, 3);
  var N = myconv(input[0], 1);
  var D = myconv(input[1], 4)[0];
  var X = myconv(input[1], 4)[1];
  let ans = 0;
  input.shift();
  input.shift();
  input = input.map((a)=>Number(a));
  for(let i = 0; i < N; i++){
    let tmp = 1;
    while (tmp <= D){
      ans++;
      tmp += input[i];
    }
  }
  console.log(ans + X);
}
Main(myin());

Measured memory_bytes: 29584
import os, sys, re, math, queue

N = int(input())
colors = [-1 for _ in range(N+1)]
nodes = {}

for _ in range(N-1):
	u,v,w = list(map(int,input().split(' ')))
	if u in nodes:
		nodes[u].append((v,w % 2))
	else:
		nodes[u] = [(v,w % 2)]

	if v in nodes:		
		nodes[v].append((u,w % 2))
	else:
		nodes[v] = [(u,w % 2)]

q = queue.Queue()
fst = list(nodes.keys())[0]
q.put((fst,0))

while not q.empty():
	pos, color = q.get()
	colors[pos] = color
	for cand in nodes[pos]:
		if colors[cand[0]] == -1:
			if cand[1] == 0:
				q.put((cand[0], color))
			else:
				q.put((cand[0], (color+1) % 2))

for i in range(N):
	print(colors[i+1])
		


Measured memory_bytes: 44056
#include<bits/stdc++.h>
using namespace std;
int ara[100005];
int main()
{
    int n,a,b,count=0,i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        ara[a]++;
    }
    for(i=0;i<=100000;i++){
        if(ara[i]>0) count++;
    }
    if((n-count) & 1) count--;
    cout<<count<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

void prim(int,int);

#define INF 1000000
#define WHITE 0
#define BLACK 1
#define NIL -1

int d[100],color[100],w[100][100];

int main(){

  int g,r,c,v,k,u,i,j;

  scanf("%d",&g);

  for(i=0;i<g;i++){
    for(j=0;j<g;j++){

      w[i][j]=INF;
      
    }
  }

  for(i=0;i<g;i++){
  
    scanf("%d%d",&u,&k);  
 
    for(j=0;j<k;j++){

      scanf("%d%d",&v,&c);
      w[u][v]=c;

      // printf("u=%d,k=%d v,c : %d,%d\n",u,k,v,c);

    }
  }

  /*for(i=0;i<g;i++){
    for(j=0;j<g;j++){

      printf("%d ",w[i][j]);

    }
    printf("\n");
    }*/

  r=0;

  
  prim(g,r);
  
  for(v=0;v<g;v++){
    
    printf("%d %d\n",v,d[v]);
  }
  
  return 0;
}

void prim(int G,int r){

  int u,mincost,i,pi[100],v,count=0;

  for(u=0;u<G;u++){

    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[r] = 0;

  while(1){

    //printf("wa-i2\n");

    mincost = INF;

    for(i=0;i<G;i++){

      if(color[i] != BLACK && d[i] < mincost){

	mincost = d[i];
	u = i;

      }
    }

    if(mincost == INF)break;

    color[u] = BLACK;
    count++;

    for(v=0;v<G;v++){

      if(color[v] != BLACK && d[u]+w[u][v] < d[v]){

	pi[v] = u;
	d[v] =d[u] + w[u][v];

      }
    }

    if(count == G)break;
    

  }
}

Measured memory_bytes: 640
def resolve():
    import sys
    import os
    input = sys.stdin.readline
    
    S = input().rstrip(os.linesep)
    pre = S[:2]
    suf = S[2:]

    def can_MM(string):
        if int(string) <= 12 and int(string) >= 1: # MM or YY
            return True
        else:
            return False

    pre_mm = can_MM(pre)
    suf_mm = can_MM(suf)

    if pre_mm:
        if suf_mm:
            print("AMBIGUOUS")
            return
        else:
            print("MMYY")
            return
    else:
        if suf_mm:
            print("YYMM")
            return
        else:
            print("NA")
            return
    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int s[10],i,t=0;
	for(i=0;i<10;i++){
		scanf("%d",&s[i]);
	}
	for(i=0;i<10;i++){
		t=t+s[i];
	}
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

int main(){
	int input;
	scanf("%d",&input);
 
	long long ans=0;
 
	for(int i = 1; i <= input; i++){
 		if(i % 3 != 0 && i % 5 != 0){
 			ans += i;
			}
		}
 	printf("%lld\n",ans);
 	return 0;
 }


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

typedef long long ll;
#define pii pair<int ,int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005
int a[5];
int b[5];

int main()
{
    _FastIO;
  	cin >> a[0] >> a[1] >> a[2];
  	sort(a , a + 3);
    cout << a[2] - a[0] <<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

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

  int a, b, c; cin >> a >> b >> c;
  int ans = min(c, b+a+1);
  ans += b;
  cout << ans << endl;
}

Measured memory_bytes: 256
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 3000, T = 3000;

int aa[N], bb[N], dp[N][T], dq[N][T];

int main() {
	int n, t; cin >> n >> t;
	for (int i = 0; i < n; i++)
		cin >> aa[i] >> bb[i];
	for (int i = 0; i + 1 < n; i++) {
		int a = aa[i], b = bb[i];
		for (int x = t - 1; x >= 0; x--) {
			dp[i + 1][x] = dp[i][x];
			if (x + a < t)
				dp[i + 1][x + a] = max(dp[i + 1][x + a], dp[i][x] + b);
		}
	}
	for (int i = 0; i + 1 < n; i++) {
		int a = aa[n - 1 - i], b = bb[n - 1 - i];
		for (int x = t - 1; x >= 0; x--) {
			dq[i + 1][x] = dq[i][x];
			if (x + a < t)
				dq[i + 1][x + a] = max(dq[i + 1][x + a], dq[i][x] + b);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int p = i, q = n - 1 - i;
		for (int x = t - 1, y = 0, z = 0; x >= 0; x--, y++)
			ans = max(ans, dp[p][x] + bb[i] + (z = max(z, dq[q][y])));
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 73824
my @ts = split //, do { my $l = <STDIN>; chomp $l; $l };

my $pattern1_count = 0;
my $color = 0;
for (@ts) {
    if ($_ != $color) {
        $pattern1_count++;
    }

    $color ^= 1;
}

my $pattern2_count = 0;
$color = 1;
for (@ts) {
    if ($_ != $color) {
        $pattern2_count++;
    }
    $color ^= 1;
}

print( ($pattern1_count <= $pattern2_count ? $pattern1_count : $pattern2_count), "\n" );


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 9e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int k,n;
	cin >> n >> k;
	ll x[n], y[n];
	FOR(i,0,n)cin >> x[i] >> y[i];
	ll ans = LLINF;
	FOR(i,0,n)FOR(j,i,n)FOR(l,j,n)FOR(m,l,n){
		ll left,right,down,up;
		left = min(x[i], min(x[j], min(x[l], x[m])));
		right = max(x[i], max(x[j], max(x[l], x[m])));
		down = min(y[i], min(y[j], min(y[l], y[m])));
		up = max(y[i], max(y[j], max(y[l], y[m])));
		int cnt = 0;
		FOR(k,0,n){
			if(left <= x[k] && x[k] <= right && down <= y[k] && y[k] <= up)
				cnt++;
		}
		//cout << i << " " << j << " " << l << " " << m << " " << cnt << " " << (right - left) * (up - down) << endl;
		if(cnt >= k)ans = min(ans, (right - left) * (up - down));
	}
	ANS(ans);
	return 0;
}


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 = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String[] s = sc.next().split("");

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length; i++) {
            if (i == k - 1) {
                sb.append(s[i].toLowerCase());
            } else {
                sb.append(s[i]);
            }
        }

        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int L[100];

int main()
{
    long long X, K, D, d, max_steps;

    scanf("%lld%lld%lld", &X, &K, &D);
    if(X < 0)
        X *= -1;

    max_steps = X / D;
    X -= min(max_steps, K) * D;
    K -= min(max_steps, K);

    K %= 2;
    if(K)
        X -= D;

    printf("%lld", abs(X));

    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string N;
  int k, s, sum = 0;
  cin >> N;
  s = N.size();
    
  int i = N.at(0) - '0';
  for(int i = 0; s > i; i++){
    k = N.at(i) - '0';
    sum += k;
  }
  if(sum % 9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define maxn 1000010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

vector<int> prime;
bool mark[maxn];

void sieve() {
  prime.push_back(2);
  for (int i = 3; i * i <= maxn; i += 2) {
    if (!mark[i]) {
      for (int j = i * i; j <= maxn; j += i + i) mark[j] = 1;
    }
  }
  for (int i = 3; i <= maxn; i += 2) {
    if (!mark[i]) prime.push_back(i);
  }
}

int f(ll num) {
  int cnt = 1;
  for (int i = 0; i < (int)prime.size() && prime[i] * prime[i] <= num; ++i) {
    if (num % prime[i] == 0) {
      cnt++;
      while (num % prime[i] == 0) {
        num /= prime[i];
      }
    }
  }
  if (num > 1) cnt++;
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  sieve();
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cout << f(g) << endl;
}


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

typedef long long ll;

int main(void){
    ll k;
    cin>>k;
    cout<<50<<endl;
    ll a = k/50;
    rep(i,50){
        if(a==k/50+50-k%50){
            a++;
        }
        cout<<a<<" ";
        a++;
    }
    cout<<endl;
    return 0;
}

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

int main() {
    int score[100];
    int i,j;
    int n;
    int tmp;
    int sum;
    int scorel;
    
    while(1){
        sum = 0;
        cin >> n;
        if(n == 0){
            break;
        }
        
        for(i = 0;i < n;i++){
            cin >> score[i];
        }
        
        for(i = 0;i < n - 1;i++){
            for(j = i + 1;j < n;j++){
                if(score[i] > score[j]){
                    tmp = score[i];
                    score[i] = score[j];
                    score[j] = tmp;
                }
            }
        }
        
        for(i = 1;i < n - 1;i++){
            sum = sum + score[i];
        }
        
        scorel = sum / (n - 2);
        
        cout << scorel << endl;
        
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 3e5 + 10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;

int h1,w1,m,bsum=0,csum=0,bs,cs;
ll a[MAX],b[MAX],c[MAX],d[MAX];

void solve() {
    cin>>h1>>w1>>m;
    for (int i=1;i<=m;++i)  cin>>a[i]>>d[i],b[a[i]]++,c[d[i]]++;
    for (int k = 1; k <=h1; ++k) {
        if (b[k]>bsum)bsum=b[k],bs=1;
        else if (b[k]==bsum) bs++;
    }
    for (int k = 1; k <=w1; ++k) {
        if (c[k]>csum)csum=c[k],cs=1;
        else if (c[k]==csum) cs++;
    }
    int flag=0;
    for (int j=1;j<=m;++j)
        if (b[a[j]]==bsum&&c[d[j]]==csum)flag++;
    //cout<<bs<<" "<<cs<<" "<<flag<<" "<<bsum<<" "<<csum<<endl;
    cout<<bsum+csum-(cs*bs==flag);
}

int main() {
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 12976
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    int left=1, right=n;
    int i;
    for(i=0; i<m; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        left=MAX(left,l);
        right=MIN(right,r);
    }
    printf("%d\n", MAX(0,right-left+1));

    return 0;
}



Measured memory_bytes: 128
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    count = 0
    for i in range(1, n-1) :
        for j in range(i+1, n) :
            for k in range(j+1, n+1) :
                if i + j + k == m :
                    count += 1
    print(count)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, j, t=1, b=0, sum=1;
  cin >> N;
  vector<int> card(N, 0);
  
  for(i=1; i<N+1; i++){
    cin >> card[i];
  }
  for(i=0; i<N; i++){
    t = card[t];
    if(t == 2){
      cout << i+1 << endl;
      break;
    }
  }
  if(i == N)
    cout << -1 << endl;
}
  

Measured memory_bytes: 640
import math
n, d = [int(i) for i in input().split()]
x = []
for i in range(n):
    x.append([int(_) for _ in input().split()])
cnt = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        a = math.sqrt(sum([(x[i][k] - x[j][k]) ** 2 for k in range(d)]))
        if a == int(a):
            cnt += 1
print(cnt//2)

Measured memory_bytes: 3064
use std::*;
use std::collections::*;
// template {{{
macro_rules ! get {($ ($ t : tt ) ,*; $ n : expr ) => {{let stdin = std :: io :: stdin () ; let ret = std :: io :: BufRead :: lines (stdin . lock () ) . take ($ n ) . map (| line | {let line = line . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } ) . collect ::< Vec < _ >> () ; ret } } ; ($ ($ t : tt ) ,* ) => {{let mut line = String :: new () ; std :: io :: stdin () . read_line (& mut line ) . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } } ; }
macro_rules ! _get {($ it : ident ; [char ] ) => {_get ! ($ it ; String ) . chars () . collect ::< Vec < _ >> () } ; ($ it : ident ; [u8 ] ) => {_get ! ($ it ; String ) . bytes () . collect ::< Vec < _ >> () } ; ($ it : ident ; usize1 ) => {$ it . next () . unwrap () . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 } ; ($ it : ident ; [usize1 ] ) => {$ it . map (| s | s . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 ) . collect ::< Vec < _ >> () } ; ($ it : ident ; [$ t : ty ] ) => {$ it . map (| s | s . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) ) . collect ::< Vec < _ >> () } ; ($ it : ident ; $ t : ty ) => {$ it . next () . unwrap () . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) } ; ($ it : ident ; $ ($ t : tt ) ,+ ) => {($ (_get ! ($ it ; $ t ) ) ,* ) } ; }
// }}}

fn main() {
    let k = get!(i32);
    for _ in 0..k {
        print!("ACL");
    }
    println!("");
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int n;
vector<pii> G[MAX];
int ans[MAX];

void dfs(int v, int pv, int col){
    ans[v] = col;
    for(pii e: G[v])if(e.fi != pv){
        dfs(e.fi, v, col^e.se);
    }
}

int main(){
    scanf("%d", &n);
    rep(i, n-1){
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        --u; --v;
        w %= 2;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }
    dfs(0, -1, 0);
    rep(i, n) printf("%d\n", ans[i]);
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
  }
  sort(a.begin(), a.end());
  int c = a[n / 2];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(a[i] - c);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
// using no_way as a way
// using no_limitation as a limitation

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}


int main(int argc, char const *argv[])
{
    // file();
    fast();
    
    int n; cin>>n;
    string s; cin>>s;
    assert(s.size() == n);
    ull r = 0, g = 0, b = 0;
    for (int i = 0; i < n; ++i)
    {
        r+=(s[i] == 'R');
        g+=(s[i] == 'G');
        b+=(s[i] == 'B');
    }

    ull ans = r * g * b;

    for (int i = 0; i < n - 1; ++i)
    {
        for (int j = 1; j < n; ++j)
        {
            int L = i - j, R = i + j;

            ans-=(L >= 0 and R < n and s[L] != s[i] and s[R] != s[i] and s[L] != s[R]);
        }
    }

    cout<<ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

string s;

int mp[5];

main ()
{
    cin >> s;
    for (int i = 0; i < sz(s); i++)
        mp[ s[i] - 'a' ]++;

    if ( abs(mp[0] - mp[1]) <= 1 && abs(mp[1] - mp[2]) <= 1 && abs(mp[2] - mp[0]) <= 1 )
        puts("YES");
    else
        puts("NO");
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int n;
    cin>>n;
    if(n<30)
    {
        cout<<"No";
    }
    else cout<<"Yes";
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--) solve();
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5;
int n, a[MAXN + 5];

int main() {
    read(n);
    for (int i = 1; i <= n; ++i) read(a[i]);
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 1; i <= n; ++i)
        if (i + 1 > a[i + 1]) {//ÕÒµ½ÒÔÔ­µãÎª×óÏÂ½ÇµÄ×î´óÕý·½ÐÎ£¬ÆäÓÒÉÏ·½¶¥µãÎª (i, i) 
            int j = 0;
            for (; a[j + i + 1] == i; ++j);
            if (((a[i] - i) & 1) || (j & 1)) puts("First");
            else puts("Second");
            break;
        }
    return 0;
}

Measured memory_bytes: 3984
n=int(input())
#n,m=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import fractions
#gcd=fractions.gcd(a,b)#最大公約数
#lcm=(a*b)/fractions.gcd(a,b)#最小公倍数
gcd=al[0]
for i in range(1,n):
    gcd=fractions.gcd(gcd,al[i])

print(gcd)


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

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

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi A(N);
  int mx = 0,smx = 0;
  each(x, A) {
    in(x);
    if (x > mx) {
      smx = mx;
      mx = x;
    } else if (x > smx) {
      smx = x;
    }
  }
  each(x, A) {
    if (x == mx) print(smx);
    else print(mx);
  }
}


Measured memory_bytes: 2432
s = raw_input()
noflag = True
for i in xrange(len(s)-2):
    w = s[i:i+3]
    d = {}
    for x in w:
        d.setdefault(x, 0)
        d[x] += 1

    if max(d.items(), key = lambda x:x[1])[1] == 2:
        print i+1, i+3
        noflag = False
        break

for i in xrange(len(s)-1):
    if noflag and s[i:i+2] == s[i]+s[i]:
        print i+1, i+2
        noflag = False
        break
if noflag:
    print "-1 -1"

Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
#include <vector>
#include <cmath>
using namespace std;
#define fi first
#define se second
#define ll long long int
int main(){
    ll a, cnt=0;
    cin>>a;
    ll arr[a];
    for (ll i=0; i<a; i++) cin>>arr[i];
    for (ll i=0; i<a; i++){
        for (ll j=i+1; j<a; j++){
            for (ll k=j+1; k<a; k++){
                if (arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k] && arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i]) cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3632
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

from collections import deque
from heapq import heappop, heappush
def main():
        

    def dijkstra(k):
        def push(v, x):
            if dist[v] <= x:
                return
            dist[v] = x
            heappush(q, (x, v))

        inf = 10**18
        dist = [inf]*n
        q = []
        push(k, 0)
        while q:
            x, v = heappop(q)
            if x > dist[v]:
                continue
            for nv, c in g[v]:
                push(nv, x+c)
        return dist

    n = ii()
    g = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b, c = mi()
        a -= 1
        b -= 1

        g[a].append((b, c))
        g[b].append((a, c))
    q, k = mi()
    k -= 1
    dist = dijkstra(k)
    for i in range(q):
        a, b = mi()
        a -= 1
        b -= 1
        print(dist[a]+dist[b])


if __name__ == '__main__':
    main()

Measured memory_bytes: 50628
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {


        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = line[0];
        var A = line[1];
        var B = line[2];

        if (N * A > B)
        {
            Console.WriteLine(B);
        }
        else
        {
            Console.WriteLine(N * A);
        }


    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		
		//入力表示
		 int N= scanner.nextInt();
		 int M =scanner.nextInt();
		 
		 //計算表示
		System.out.println(N*(N-1)/2+M*(M-1)/2); 
		
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
string S;


//解法
void solve() {

	ll w = 0, b = 0;

	rep(i, S.size()) {
		if (S[i] == '0') {
			w++;
		}
		else {
			b++;
		}
	}

	cout << min(w, b) * 2;

	return;
}

int main() {

	//入力
	cin >> S;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << "x";
    }
}

Measured memory_bytes: 3580
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)

R,G,B,N=gets.split.map(&:to_i)

X,Y,Z=[R,G,B].sort

count=0


xs=0
while xs<=N
  ys=0
  while ys+xs<=N
    count+=1 if (N-(ys+xs))%Z==0
    ys+=Y
  end
  xs+=X
end


puts count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int>G[maxn];
int n, k, val[maxn], fa[maxn], now[maxn], dif[maxn];
inline void Add(int u, int v) {
	int x = dif[v] + 1;
	if(dif[u] < 1e7 && dif[v] < 1e7 && (abs(now[u] + dif[u]) % 2 != abs(now[v] + x) % 2))
		exit(0 * puts("No"));
	int l = max(now[u] - dif[u], now[v] - x), r = min(now[u] + dif[u], now[v] + x);
	// cerr << "Add " << v << "->" << u <<": " << l <<" " << r << endl;
	if(l > r)
		exit(0 * puts("No"));
	assert((l + r) % 2 == 0);
	now[u] = (l + r) >> 1, dif[u] = r - now[u];
}
inline void Solve(int u) {
	for(auto v : G[u])
		if(v != fa[u])
			fa[v] = u, Solve(v), Add(u, v);
}
inline void Work(int u) {
	val[u] = now[u] - dif[u], now[u] = val[u], dif[u] = 0;
	for(auto v : G[u])
		if(v != fa[u])
			Add(v, u), Work(v);
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i)
		dif[i] = 1e7;
	for(int i = 1, x, y; i < n; ++ i)
		scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
	scanf("%d", &k);
	for(int i = 1, x, y; i <= k; ++ i)
		scanf("%d%d", &x, &y), now[x] = y, dif[x] = 0;
	Solve(1), Work(1), puts("Yes");
	for(int i = 1; i <= n; ++ i)
		printf("%d\n", val[i]);
}

Measured memory_bytes: 18632
#include <iostream>

using namespace std;

string s;
int cnt[26];
void solve() {
  for (int i=0;i<s.size();i++) {
    cnt[s[i] - 'A']++;
  }
  for (int i=0;i<26;i++) {
    if (cnt[i] != 0 && cnt[i] != 2) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
  cin >> s;
  solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define SIZE 3005

  const int mod = (int)1e9 + 7;
  int dp[SIZE][SIZE];
  char str[SIZE];

  inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
  inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}

  int main(void) {
        int n;
        scanf("%d",&n);
        for(int i=0; i<n-1; i++) scanf(" %c",&str[i]);

        dp[1][1] = 1;
        for(int len=2; len<=n; len++) {
                for(int i=1; i<=len-1; i++) dp[len-1][i] = add(dp[len-1][i-1], dp[len-1][i], mod);

                for(int b=1; b<=len; b++) {
                        int l=1, r=b-1;
                        if(str[len-2] == '>') l = b, r = len - 1;
                        if(l > r) continue;

                        dp[len][b] = add(dp[len][b], sub(dp[len-1][r], dp[len-1][l-1], mod), mod);
                }
        }

        int ans=0;
        for(int i=1; i<=n; i++) ans = add(ans, dp[n][i], mod);

        printf("%d", ans);
        return 0;
  }




Measured memory_bytes: 34048
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define mod 1000000007

int ar[101], l[101];
vector<pair<int, int>> vv[101];

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        lp(j, n) {
                int a; cin >> a;
                lp(i, a) {
                        int u, v; cin >> u>> v;
                        vv[j].push_back({u, v});
                }
        }
        int mx = 0;
        for (int i = 0; i < 1<<n; i++) {
                int one = 0;
                for (int j = 0; j < n; j++) {
                        if (i & 1<<(j)) {
                                ar[j] = 1;
                                l[j] = 1;
                                one++;
                        } else { ar[j] = -1; l[j] = -1;}
                }
                bool con = 0;
                for (int j = 0; j < n; j++) {
                        if (ar[j] == 1) {
                                lp(k, vv[j].size()) {
                                        if (l[vv[j][k].first - 1] == -1) {
                                                l[vv[j][k].first - 1] = vv[j][k].second;
                                        } else if (l[vv[j][k].first - 1] != vv[j][k].second) {
                                                        con = 1;
                                        }
                                }
                        }
                }
                for (int j = 0; j < n; j++) {
                        if (l[j] == 1) {
                                lp(k, vv[j].size()) {
                                        if (l[vv[j][k].first - 1] == -1) {
                                                l[vv[j][k].first - 1] = vv[j][k].second;
                                        } else if (l[vv[j][k].first - 1] != vv[j][k].second) {
                                                        con = 1;
                                        }
                                }
                        }
                }
                for (int j = 0; j < n; j++) {
                        if (l[j] == 1) {
                                lp(k, vv[j].size()) {
                                        if (l[vv[j][k].first - 1] == -1) {
                                                l[vv[j][k].first - 1] = vv[j][k].second;
                                        } else if (l[vv[j][k].first - 1] != vv[j][k].second) {
                                                        con = 1;
                                        }
                                }
                        }
                }
                if (!con) {
                        mx = max(mx, one);
                }
        }
        cout << mx;
return 0;
}


Measured memory_bytes: 256
Sa = input()
Sb = input()
Sc = input()
ai = 0
bi = -1
ci = -1


def fn(s):
    global ai
    global bi
    global ci
    if s == 'a':
        ai += 1
        if len(Sa) == ai:
            print('A')
            exit()
        fn(Sa[ai])
    elif s == 'b':
        bi += 1
        if len(Sb) == bi:
            print('B')
            exit()
        fn(Sb[bi])
    elif s == 'c':
        ci += 1
        if len(Sc) == ci:
            print('C')
            exit()
        fn(Sc[ci])


fn(Sa[0])


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main() {
	int H, W, D;
	cin >> H >> W >> D;
	if (D % 2 == 1) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cout << ((i + j) % 2 == 0 ? "R" : "B");
			}
			cout << endl;
		}
	}
	else {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				int tx = i + j, ty = i - j + W;
				int cx = (tx / D) % 2, cy = (ty / D) % 2;
				cout << string("RBGY")[cx * 2 + cy];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define END << endl;
#define SP << " " << 
using namespace std;

int main(){
	int c[26];
	int sc[26];
	int p;
	int ac;
	char t;
	cin >> p;
	bool f = true;
	while(p != 0){
		REP(i,26)c[i] = 0;
		REP(i, p){
			cin >> t;
			c[t-65]++;
			REP(j,26)sc[j] = c[j];
			sort(sc,sc+26);
			if(sc[25]>sc[24]+p-i-1){
				REP(j,26)if(c[j]==sc[25])ac = j+65;
				if(f){
					cout << (char)ac SP i+1 END
					f = false;
				}
			}
			else if(i == p-1&&f) cout << "TIE" END
		}
		f = true;
		cin >> p;
	}
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
int A[3][200];

int dp[3][200];

int main() {
  while (cin >> N) {
	for (int i = 0; i < 2; ++i) for (int j = 0; j <  N; ++j) cin >> A[i][j];
	memset(dp, 0, sizeof(dp));

	dp[0][0] = A[0][0];
	for (int i = 0; i < 2; ++i) {
	  for (int j = 0; j < N; ++j) {
		if (i > 0) chmax(dp[i][j], dp[i-1][j] + A[i][j]);
		if (j > 0) chmax(dp[i][j], dp[i][j-1] + A[i][j]);
	  }
	}

	cout << dp[1][N-1] << endl;
  }
}

	


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for C - Train Ticket
	var S string
	fmt.Scanf("%s", &S)

	var sum int
	var ans int
	for i := 0; i < (1 << 3); i++ {
		sum, _ = strconv.Atoi(string(S[0]))
		//fmt.Println(sum)
		for j := 0; j < 3; j++ {
			temp, _ := strconv.Atoi(string(S[j+1]))
			//fmt.Printf("%d", i>>j&1)
			if i>>j&1 == 1 {
				sum += temp
				//fmt.Println(sum)
			} else {
				sum -= temp
			}
		}
		//fmt.Printf("\n")
		if sum == 7 {
			ans = i
			break
		}
	}

	for i := 0; i < 3; i++ {
		fmt.Printf("%s", string(S[i]))
		if ans>>i&1 == 1 {
			fmt.Printf("%s", string("+"))
		} else {
			fmt.Printf("%s", string("-"))
		}
	}
	fmt.Printf("%s=7\n", string(S[3]))
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[600000], vs[600000], dp[4000][4000], fs[500][500];
map<int,int>mp;
string s , s1;
ll f(ll l, ll r)
{
    ll i, j, n;
    if(l==r) return a[l];
    if(dp[l][r]!=-1e18) return dp[l][r];
    j = max(a[l]-f(l+1,r),a[r]-f(l,r-1));
    dp[l][r]=j; return j;
}
int main()
{
    IO;
    ll j=0, n, m, k, m1, m2, a1=0, a2=0, l  = 1, t=3, mn, cnt=0, mx=0, h=0, mod=1e8+7, i; int tc=0;
    //cin>>t;
    //while(t--){
        cin>>n;
        for(i=1; i<=n; i++)
            for(j=1; j<=n; j++) dp[i][j]=-1e18;
        for(i = 1; i<=n; i++)
              cin>>a[i];

        j = f(1, n); cout<<j<<endl;

    //}
    return 0;
}



Measured memory_bytes: 96768
#include <bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin>>n;
  int x=0;
  for(int i=0;i<n.size();i++){
    if(n.at(i)=='7'){
      x+=1;}
  }
  if(x>0){
   cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}
     
 


Measured memory_bytes: 3628
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
  
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
const int MAX = 1e5+5;
int h[MAX];
int dp[MAX];

ll frog(int n){

    for( int i = 2; i < n; i++)
        dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i])  );
    return dp[n-1];
    
}
int main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin) ;
    // freopen("output.txt", "w", stdout) ;
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    dp[0] =  0;
    dp[1] =  abs(h[1]-h[0]);
    ll a = frog(n);
    cout<<a<<"\n"; 


    return 0 ;

}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		long X = GetLong();
		long Y = GetLong();
		Console.WriteLine((Math.Abs(X - Y) > 1) ? "Alice" : "Brown");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 11220
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val a = readIntList()

    println(if (n >= a.sum()) n - a.sum() else -1)
}


Measured memory_bytes: 39440
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
int main(){
    int n; cin >> n;
    ll x = 1, y = 1; 
    rep(i, n){
        ll a, b; cin >> a >> b;
        ll MAX = max((a + x - 1) / a, (b + y - 1) / b);
        x = MAX * a;
        y = MAX * b;
        //cout << x << " " << y << endl;
    }
    cout << x + y << endl;
}

Measured memory_bytes: 3572
#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;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, x;
int l[100];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>x;
    for(int i=0;i<n;i++)cin>>l[i];
    int ans=1;
    ll d=0;
    for(int i=0;i<n;i++){
        d=d+l[i];
        if(d<=x){
            ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
s = input()

if s[0] != "A":
    print("WA")
    quit()

if s[2:-1].count("C") != 1:
    print("WA")
    quit()

if s[0:2].count("C") != 0 and s[-2:].count("C") != 0:
    print("WA")
    quit()

for _s in s:
    if _s == "A" or _s == "C":
        continue

    if not _s.islower():
        print("WA")
        quit()

print("AC")


Measured memory_bytes: 3060