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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll MOD = 1000000000 + 7;

std::vector<int> v[25];
int N;
ll dp[25][1<<21];
int A[25];

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

    std::cin >> N;

    for(int i=0;i<(1<<N);++i){
        v[__builtin_popcount(i)].emplace_back(i);
    }

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

            if(a > 0){
                A[i] |= 1 << j;
            }
        }
    }

    dp[0][0] = 1;

    for(int i=0;i<N;++i){
        for(int j : v[i]){
            for(int k=0;k<N;++k){
                if((j >> k & 1) == 0 &&
                   (A[i] >> k & 1) == 1){
                    dp[i + 1][j | (1 << k)] = (dp[i + 1][j | (1 << k)] + dp[i][j]) % MOD;
                }
            }
        }
    }

    ll res = dp[N][(1<<N)-1];
    std::cout << res << std::endl;
}


Measured memory_bytes: 320956
import java.util.Scanner;

//Space Coconut Grab
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean[] Z = new boolean[1000001];
		int[] z = new int[1000001];
		for(int i=0;i<=100;i++){
			Z[i*i*i] = true;
			z[i*i*i] = i;
		}
		for(;;){
			int e = sc.nextInt();
			if(e==0)break;
			int res = 1<<29;
			for(int x=0;x<=1000000;x++){
				if(res<=x)break;
				for(int y=0;y<=1000000;y++){
					if(res<=x+y||e<x+y*y)break;
					if(!Z[e-x-y*y])continue;
					res = Math.min(res, x+y+z[e-x-y*y]);
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){	
		Scanner sc = new Scanner(System.in);
		Map<Integer, Set<Integer>> nums = new HashMap<Integer, Set<Integer>>();
		Set<Integer> three = new HashSet<Integer>();
		three.add(573);
		three.add(357);
		three.add(375);
		three.add(537);
		three.add(735);
		three.add(753);
		nums.put(3, three);
		int comparedNum = sc.nextInt();
		int n = numProducer(nums, comparedNum);
		System.out.println(n);
				
	}
	
	public static int numProducer(Map<Integer, Set<Integer>> nums, int comparedNum){
		if(comparedNum < 100) return 0;
		List<Character> cN = numToCharacter(comparedNum);
		int totalNum = 0;
		if(nums.containsKey(cN.size())){
			Set<Integer> s = nums.get(cN.size());
			for(int i : s){
				if(i <= comparedNum){
					totalNum++;
				}
			}
			int len = cN.size() - 1;
			while(nums.containsKey(len)){
				totalNum += nums.get(len).size();
				len--;
			}	
			return totalNum;
		}else{
			int len = cN.size() - 1;
			while(!nums.containsKey(len)){
				len--;
			}
			
			while(len < cN.size()){
				Set<Integer> s = nums.get(len);
				Set<Integer> total = new HashSet<Integer>();
				int[] generator = new int[]{3,5,7};
				for(int x : generator){
					Set<Integer> integers = smallNumProducer(s, x);
					total.addAll(integers);
				}
				nums.put(++len, total);
			}
			return numProducer(nums, comparedNum);
			
		}
	}
	
	public static Set<Integer> smallNumProducer(Set<Integer> list, int num){
		Set<Integer> nums = new HashSet<Integer>();
		for(int n: list){
			Set<Integer> ns = oneNumProducer(n, num);
			nums.addAll(ns);
		}
		return nums;
	}
	
	public static Set<Integer> oneNumProducer(int n, int num){
		Set<Integer> newNumbers = new HashSet<Integer>();
		List<Character> numbers = numToCharacter(n);
		for(int i = 0; i <= numbers.size(); i++){
			numbers.add(i, (char)(num + '0'));
			newNumbers.add(charToNum(numbers));
			numbers.remove(i);
		}
		return newNumbers;
	}
	
	public static int charToNum(List<Character> list){
		char[] chars = new char[list.size()];
		for(int i = 0; i < list.size(); i++){
			chars[i] = list.get(i);
		}
		String s = new String(chars);
		return Integer.parseInt(s);
	}
	
	public static List<Character> numToCharacter(int n){
		LinkedList<Character> numToChar = new LinkedList<Character>();
		while(n != 0){
			numToChar.addFirst((char)((n % 10) + '0'));
			n = n/10;
		}
		return numToChar;
	}

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  map<char, int> mplast;
  map<char, int> usable_cnt;
  rep(i, N) {
    string s; cin >> s;
    map<char, int> mp;
    for (auto c: s) {
      mp[c]++;
    }
    for (auto e: mp) {
      usable_cnt[e.first]++;
    }
    if (mplast.empty()) {
      mplast = mp;
    } else {
      for (auto e: mp) {
        mplast[e.first] = min(mplast[e.first], e.second);        
      }
    }
  }
  for (auto e: mplast) if (usable_cnt[e.first] == N) {
    rep(i, e.second) cout << e.first;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
map<long long,int> cnt;
int n;
long long a,res;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		res+=(long long)(cnt[i-a]);
		cnt[i+a]++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 26404
import java.util.ArrayList;
import java.util.Collections;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner();
        try (final FastWriter writer = new FastWriter()) {
            ArrayList<Integer> a = new ArrayList<>();
            a.add(scanner.nextInt());
            a.add(scanner.nextInt());
            a.add(scanner.nextInt());
            Collections.sort(a);
            if (a.get(0).equals(a.get(1)) && !a.get(0).equals(a.get(2))) {
                writer.println("Yes");
            } else if (a.get(2).equals(a.get(1)) && !a.get(0).equals(a.get(2))) {
                writer.println("Yes");
            } else {
                writer.println("No");
            }
        }
    }
}

class FastWriter extends PrintWriter {
    public FastWriter() {
        super(new BufferedOutputStream(System.out));
    }

    public static void main(final String[] args) {
        try (final FastWriter w = new FastWriter()) {
            w.println(32);
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (final IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007

int n;
long long a[300000];


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

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

	long long ans = 0;
	long long p2 = 1;
	rep(i, 60) {
		int cnt = 0;
		rep(j,n) {
			if (a[j] >> i&1) {
				cnt++;
			}
		}
		long long bit = 1LL * (n - cnt) * cnt % MOD;
		ans += bit * p2;
		ans %= MOD;
		p2 *= 2;
		p2 %= MOD;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int H;
  //?????????????????¶????????\???
  while (cin >> H && H>0) {
    vector< vector<int> > c(5,vector<int>(H));
    int sum = 0;
    for (int i=H-1; i>=0; i--){
      for (int j=0; j<5; j++){
	cin >> c[j][i];
      }
    }
    //????????°??????3?????\????¨???????????????´???????????°????¨??????????0?????????
    int flg = 1; //?¶?????????¨???flg == 1
    while (flg) { 
      flg = 0;
      for (int i=H-1; i>=0; i--){
	for (int j=0; j<3; j++) {
	   int cnt = 1; //?¨???????????????°
	  if (c[j][i] != 0) {
	    int flag = 1;
	    for (int k=j+1; k<5 && flag; k++) { //????¨??????????????????????
	      if (c[j][i] == c[k][i])
		cnt++;
	      if (c[j][i] != c[k][i] || k == 4) { //?????????????????£???????????????????????????
		flag = 0;
		if (cnt >= 3) { //3?????\???????????§?????¨???
		  sum += c[j][i] * cnt; //????????????
		  for (int l=j; l<=j+cnt-1; l++) { //0???????????????
		    c[l][i] = 0;
		  }
		  flg = 1;
		}
	      }
	    }
	  }
	}
      }
      for (int j=0; j<5; j++) {
	vector<int>::iterator itr = remove(c[j].begin(), c[j].end(), 0);
	for (; itr != c[j].end(); itr++) *itr = 0;
      }
    }
    //???????????????????????????0????????£??????flg==0??¨?????????????????±???
    cout << sum << endl;
  }
}

Measured memory_bytes: 1216
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var n int
	fmt.Scan(&n)
	a := atoi(nextSlice())
	sort.Ints(a)
	for i := 1; i < n; i++ {
		if a[i-1] == a[i] {
			yesorNO(false)
			return
		}
	}
	yesorNO(true)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  rep(i,s.size()) if(i%2==0) cout<<s[i];
  cout<<endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while (t--)
    {
       char mat[2][3];
       for(int i=0;i<2;i++)
       {
		   for(int j=0;j<3;j++)
		   cin>>mat[i][j];
	   }
    if (mat[1][2]==mat[0][0] && mat[0][1]==mat[1][1] &&
         mat[0][2]==mat[1][0])
         cout<<"YES\n";
    else
        cout<<"NO\n";    
	} 
    return 0;
    
}


Measured memory_bytes: 256
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Measured memory_bytes: 92728
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n, m;
string s;



int main() {
	cin >> s;
	int size = s.size();
	vector<int> vec(size);

	int cnt = 0;
	for (int i = 0; i < size; i++)
	{
		if (s[i]-'0'==((int)pow(-1,i)+1)/2)
		{
			cnt++;
		}
	}
	if (cnt>=(size+1)/2)
	{
		cnt = size - cnt;
	}
	
	cout <<cnt<< endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long H, W;
    cin >> H >> W;
    
    long long ans = (H * W + 1) / 2;
    
    if (H == 1 || W == 1) ans = 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N >> M;
	vector<ll> A(N + 1), sum(N + 1,0);
	map<ll, ll>m;
	m[0]++;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		sum[i] = sum[i - 1] + A[i];
		sum[i] %= M;
		m[sum[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); it++) {
		pair<ll, ll>item = *it;
		ans += item.second*(item.second - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
//by Judge
#include<bits/stdc++.h>
#define Rg register
#define fp(i,a,b) for(Rg int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(Rg int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(Rg int i=head[u],v=e[i].to;i;v=e[i=e[i].nxt].to)
#define open(S) freopen(S".in","r",stdin),freopen(S".out","w",stdout)
#define ll long long
using namespace std;
const double PI=acos(-1);
const int M=1e5+3;
typedef int arr[M];
#ifndef Judge
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
char buf[1<<21],*p1=buf,*p2=buf;
template<class T>inline T Min(T x,T y){return x<y?x:y;}
template<class T>inline T Max(T x,T y){return x>y?x:y;}
template<class T>inline bool cmin(T& x,T y){return x>y?x=y,1:0;}
template<class T>inline bool cmax(T& x,T y){return x<y?x=y,1:0;}
inline ll read(){ ll x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f;
} inline void sread(string& s){ char c=getchar();
	for(;!isalpha(c);c=getchar()); s=" ";
	for(;isalpha(c);c=getchar()) s+=c;
} char sr[1<<21],z[20];int CCF=-1,Z;
inline void Ot(){fwrite(sr,1,CCF+1,stdout),CCF=-1;}
inline void print(ll x,char chr='\n'){
	if(CCF>1<<20)Ot();if(x<0)sr[++CCF]=45,x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++CCF]=z[Z],--Z);sr[++CCF]=chr;
} int n,top,x[M],y[M]; double mx,stk[M];
inline double calc(int id){ top=0,mx=0;
	fp(i,1,n) if(i^id) stk[++top]=atan2(x[i]-x[id],y[i]-y[id]);
	sort(stk+1,stk+1+top),stk[0]=stk[top]-PI*2;
	fp(i,1,top) cmax(mx,stk[i]-stk[i-1]);
	return mx>PI?mx-PI:0;
}
int main(){ n=read();
	if(n==2) return !printf("0.5 0.5\n");
	fp(i,1,n) x[i]=read(),y[i]=read();
	fp(i,1,n) printf("%.10lf\n",calc(i)/(PI*2));
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int GCD(int a, int b)
{
    if(b==0)
        return a;
    return GCD(b,a%b);
}

int main()
{
    int a,b;
    cin >> a >> b;
    cout << GCD(a,b) << endl;
    return 0;
}



Measured memory_bytes: 3096
/*<---------------------------CONCEPTS LEARNT------------------------------>

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
     ll n, m ; cin >> n >> m ;
     cout << n*(n-1)/2+m*(m-1)/2 << endl ;
}
int main() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     solve() ;
     //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define sc second
using namespace std;
const int maxn = 1e5+10;
using pii = pair<int,int>;
vector<pii> G[maxn];
vector<int> ans;
int N,M;
pii arr[maxn];
bool vis[maxn];
int ca[maxn];
int dfs(int u){
    vis[u] = true;
    int st = ca[u];
    for(auto v:G[u]){
        if(vis[v.fs]) continue;
        int r = dfs(v.fs);
        if(r) {
            ans.push_back(v.sc);
            st ^= 1;
        }
    }
    return st;
}
int main(){
    cin>>N>>M;
    for(int i = 1;i<=N;i++) scanf("%d %d",&arr[i].fs,&arr[i].sc);
    sort(arr+1,arr+N+1);
    ca[1] = arr[1].sc;
    for(int i = 2;i<=N;i++) ca[i] = arr[i].sc^arr[i-1].sc;
    ca[N+1] = arr[N].sc;
    //for(int i = 1;i<=N;i++) cout<<ca[i]<<" ";cout<<endl;
    for(int i = 1;i<=M;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        int l = lower_bound(arr+1,arr+N+1,pii(a,0))-arr;
        int r = upper_bound(arr+1,arr+N+1,pii(b,1))-arr; //cout<<l<<" "<<r<<endl;
        if(l == r) continue;
        G[l].push_back({r,i});
        G[r].push_back({l,i});
    }
    for(int i = 1;i<=N;i++){
        if(vis[i]) continue;
        if(dfs(i)){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans.size()<<endl;
    sort(ans.begin(),ans.end());
    for(auto v:ans) cout<<v<<" ";

    return 0;
}

Measured memory_bytes: 15228
import java.util.Arrays;
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[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = Integer.parseInt(sc.next());
        }
        int sum = Arrays.stream(t).sum();
        int m = Integer.parseInt(sc.next());
        for (int i = 0; i < m; i++) {
            int p = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            int temp = sum;
            temp += x - t[p - 1];
            System.out.println(temp);
        }
    }
}

Measured memory_bytes: 26708
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;
#define PI 3.14159265359



int main()
{
    int N, ans = 0;
    string S;
    cin >> N >> S;
    for(int i = 0; i < S.size(); i++){
        if(S.substr(i, 3) == "ABC") ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
ls = [input() for _ in range(h)]
from collections import deque
a = 0
for i in range(h):
  for j in range(w):
    if ls[i][j]=='#': continue
    d = [[-1]*w for _ in range(h)]
    d[i][j] = 0
    q = deque([(i,j)])
    while q:
      x,y = q.popleft()
      for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
        nx,ny = x+dx,y+dy
        if not (0<=nx<h and 0<=ny<w): continue
        if ls[nx][ny]=='.' and d[nx][ny]==-1:
          d[nx][ny] = d[x][y]+1
          q.append((nx,ny))
    a = max(a,max(max(j for j in i) for i in d))
print(a)

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

int main(){
    ll n;cin >> n;
    ll maxi=0,t;
    for(int i=0;i<=n;i++){
        if(i*(i+1)/2>=n){
            maxi=i;
            t=i*(i+1)/2-n;
            break;
        }
    }
    repl(i,1,maxi+1){
        if(i==t)continue;
        cout << i <<endl;
    }
}

Measured memory_bytes: 3556
#include <stdio.h>
#include <algorithm>
#include <complex>
#include<vector>

int solve();

int main()
{
    printf("%d\n", solve());
    return 0;
}

int solve()
{
    int x, max = 1;
    scanf("%d", &x);
    for (int b = 2; b * b <= x; ++b)
    {
        for (int p = 2;; ++p)
        {
            int tmp = 1;
            for (int i = 0; i < p; ++i)
                tmp *= b;
            if (tmp > x) break;
            if (tmp > max) max = tmp;
        }
    }
    return max;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> a(3, -1);
  ll res = 1;
  rep(i, N){
    int b; cin >>b;
    ll tmp = 0;
    rep(j, 3){
      if (a[j]+1 == b){
        if (tmp == 0) a[j]++;
        tmp++;
      }
    }
    res = (res * tmp) % MOD;
  }
  cout <<res <<endl;
}


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

int main(void) {
	int K, N;
	cin >> K >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	//--------------------------------
	vector<int>itbl(N);
	for (int i = 0; i < N; i++) {
		if (i == N-1) {
			itbl[i] = K - A[N - 1] + A[0];
		}
		else {
			itbl[i] = A[i + 1] - A[i];
		}
	}
	int max = 0;
	for (int i = 0; i < N; i++) {
		if (max < itbl[i]) {
			max = itbl[i];
		}
	}
	int Ans = K - max;
	cout << Ans << endl;
}

Measured memory_bytes: 1792
def checkp(a,b,c):
    if max(a,b,c) == b or min(a,b,c) == b:
        return 0
    else:
        return 1

n = int(input())
p = list(map(int,input().split()))

count = 0

for i in range(n-2):
    count += checkp(p[i],p[i+1],p[i+2])

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = int64_t;
using namespace std;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){
      cout<<"Yes";
      break;
    }
    a-=d;
    if(a<=0){
      cout<<"No";
      break;
    }


  }

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n; cin >> n;
	string s; cin >> s;
	if (3200 <= n) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
cats = list(map(int,input().split()))
flag = True
p, q = max(cats), min(cats)
x = cats.count(p)
y = cats.count(q)
if p - q >= 2:
    flag = False
elif p == q:
    if p != n - 1 and p * 2 > n:
        flag = False
else:
    if y >= p or (p-y) * 2 > x:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13964
#include<stdio.h>

int selectionSort(int A[], int N){
  int i, j, t, sel = 0, minj;
  for(i = 0; i < N-1 ; i++){
    minj = i;
    for( j = i ; j < N ; j++){
      if( A[j] < A[minj] ) minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
    if( i != minj ) sel++;
  }
  return sel;
}

int main(){
  int i, N, sel;
  int A[100];
  scanf("%d", &N);
  for( i = 0 ; i < N; i++){
    scanf("%d", &A[i]);
  }

  sel = selectionSort(A, N);

  for(i = 0 ; i < N ; i++){
    if( i>0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n",sel);
}



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

typedef long long ll;
typedef pair <int, int> ii;

const int mod1 = 3;
const int mod2 = 673;
const int Maxn = 200005;

char str[Maxn];
int slen;
map <ii, int> M;
ll res;

int toPower(int a, int p, int mod)
{
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x, int mod) { return toPower(x, mod - 2, mod); }

int main()
{
    scanf("%s", str + 1);
    slen = strlen(str + 1);
    M[ii(0, 0)] = 1;
    int inv1 = Inv(10 % mod1, mod1);
    int inv2 = Inv(10 % mod2, mod2);
    int cur1 = 1, cur2 = 1;
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= slen; i++) {
        sum1 = (10ll * sum1 + ll(str[i] - '0')) % mod1;
        sum2 = (10ll * sum2 + ll(str[i] - '0')) % mod2;
        cur1 = ll(cur1) * inv1 % mod1;
        cur2 = ll(cur2) * inv2 % mod2;
        ii my = ii(sum1 * cur1 % mod1, sum2 * cur2 % mod2);
        res += M[my];
        M[my]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3976
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    int a,b;
    scanf("%d %d\n", &a, &b);

    if((a+b)%2==0){ printf("%d\n", (a+b)/2); }
    else{ printf("IMPOSSIBLE\n"); }
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main() {
	int n, m;
	int mx;
	int in, out;
	int flag = 0;
	scanf("%d", &n);
	scanf("%d", &m);
	mx = m;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &in, &out);
		m = m + in - out;
		if (m < 0) {
			flag = 1;
		}
		if (m > mx)mx = m;
	}
	if (flag)printf("0\n");
	else printf("%d\n", mx);
	return 0;
}


Measured memory_bytes: 2104
MAX_NUM = int(1E4 + 1)

if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = sorted(A)
    smallest = sorted_A[0]
    correct_pos = [0] * MAX_NUM
    flag_A = [False] * MAX_NUM
    for i, val in enumerate(sorted_A):
        correct_pos[val] = i

    ans = 0
    for i in range(len(A)):
        if flag_A[A[i]]:
            continue
        next_pos = i
        sum = 0
        m = 1E4
        an = 0
        while True:
            an += 1
            val = A[next_pos]
            sum += val
            m = min([m, val])
            flag_A[A[next_pos]] = True
            next_pos = correct_pos[val]
            if flag_A[A[next_pos]]:
                break
        ans += min([sum + (an - 2) * m, m + sum + (an + 1) * smallest])

    print(ans)

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define ll long long
int main(){
	ll n,x;
	bool a=1; cin>>n;
	while(n--){
		cin>>x;
		if(x&1) continue;
		if(x%3==0 or x%5==0) continue;
		a=0;
	} 
	if(a) cout<<"APPROVED";
	else cout<<"DENIED";
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    ll N; cin >> N;
    ll ans = N*(N-1)/2;

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


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int cnt_0_section = 0;
    int flag = 1;
    vector<pair<int, int>> sections;
    sections.push_back({-1, -1});
    int first_idx;
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') {
            if (flag == 1) {
                cnt_0_section += 1;
                first_idx = i;
                flag = 0;
            }
        } else {
            if (flag == 0) {
                sections.push_back({first_idx, i - 1});
            }
            flag = 1;
        }
    }
    if (flag == 0) {
        sections.push_back({first_idx, N - 1});
    }
    sections.push_back({N, N});
    if (K >= cnt_0_section) {
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    for (int i = 1; i <= cnt_0_section - K + 1; i++) {
        ans = max(ans, sections[i + K].first - sections[i - 1].second - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())
/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


ll expo(ll num,ll p)
{
    ll ans = 1;

    for(;p>=1;p/=2,num=(num*num)%mod)
    {
        if(p%2)
            ans = (ans*num)%mod;
    }

    return ans;

}


int main()
{

    ll n,Z=26,N,S,M,ans=0,i,t1=1,t2=0,v1,v2,v3;
    string s;

    cin>>n>>s;

    S = s.size();

    N = S+n;

    ll fac[N+1],exp[N+1];

    fac[0]=1;
    exp[0]=1;

    rep(i,1,N+1)
    {
        fac[i] = (fac[i-1]*i)%mod;
        exp[i] = (exp[i-1]*(Z-1))%mod;
        t1 = (t1*26)%mod;
    }


    for(M=0;M<=(S-1);++M)
    {
    
        v1 = (fac[N]*exp[N-M])%mod;

        v2 = (fac[M]*fac[N-M])%mod;

        v2 = expo(v2,mod-2);

        v1 = (v1*v2)%mod;

        t2 = (t2+v1)%mod;

    }

    ans = (t1-t2)%mod;

    ans = (ans+mod)%mod;

    cout<<ans<<"\n";


    return 0;
}

Measured memory_bytes: 35556
#include<stdio.h>
int main()
{
	int i=0;
	char y;
	int n;
	int k;
	int cnt=0;
	scanf("%d %d",&n,&k);
	int high[n];
	do{
		scanf("%d",&high[i]);
		i++;
	}while(y=getchar()!='\n');
	for(i=0;i<n;i++){
		if(high[i]>=k){
			cnt++;
		}
	}printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	ll a, b, z[100][100] = {};
	cin >> a >> b;
	bool x;
	char c[100][100];
	for (ll i = 0; i < a; i++) {
		x = true;
		for (ll j = 0; j < b; j++) {
			cin >> c[i][j];
			if (c[i][j] != '.') x = false;
		}
		if (x) {
			for (int j = 0; j < b; j++) {
				z[i][j] = 1;
			}
		}
	}
	for (ll i = 0; i < b; i++) {
		x = true;
		for (ll j = 0; j < a; j++) {
			if (c[j][i] != '.') x = false;
		}
		if (x) {
			for (int j = 0; j < a; j++) {
				z[j][i] = 1;
			}
		}
	}
	for (ll i = 0; i < a; i++) {
		for (ll j = 0; j < b; j++) {
			if (z[i][j] != 1) cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	for _, e := range a {
		if e == 0 {
			fmt.Println(0)
			return
		}
	}

	bigAns := big.NewInt(1)
	for _, e := range a {
		bigAns = bigAns.Mul(bigAns, big.NewInt(e))
		if bigAns.Cmp(big.NewInt(1000000000000000000)) == 1 {
			fmt.Println(-1)
			return
		}
	}

	fmt.Println(bigAns)
}


Measured memory_bytes: 6488
#include<iostream>
#include<set>
using namespace std;
using ll = long long;
int L = 1000000007;

int main() {
	int N; cin >> N;
	multiset <int>A;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		A.insert(a);
	}
	if (N % 2) {
		if (A.count(0) != 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	else {
		if (A.count(0) != 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	int i = 1;
	if (N % 2) i++;
	for (; i < A.size(); i += 2) {
		if (A.count(i) != 2) {
			cout << 0 << endl;
			return 0;
		}
	}
	int res = 1;
	for (int i = 0; i < N / 2; i++) {
		res *= 2;
		res %= L;
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                 
                var st = Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => int.Parse(x))
                    .ToArray();
                int n = st[0];
                int m = st[1];
                int p = st[2];
                if (n + m + p == 0)
                    break;
                var ls = new List<int>();
                var coun = 0;
                for (int i = 0; i < n; i++)
                {
                    var a = int.Parse(Console.ReadLine());
                    coun += a;
                    ls.Add(a);
                }
                var money = 100 * coun * 0.01 * (100 - p);
                if (ls[m - 1] != 0)
                    Console.WriteLine(((int)money / ls[m-1]));
                else
                    Console.WriteLine(0);
            }
        }
         
    }
 
}


Measured memory_bytes: 9540
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    string S;
    cin >> S;
 
    vector<string> tokens = { "dreamer", "dream","erase", "eraser"};
 
    while (S.size() > 0) {
        bool hit = false;
        for(int i=0; i<tokens.size(); i++) {
            string t = tokens[i];
            if (S.size() >= t.size() && S.substr(S.size() - t.size(), t.size()) == t) {
                S = S.substr(0, S.size() - t.size());
                hit = true;
                break;
            }
        }
        if (!hit) {
            cout << "NO" << endl;;
            return 0;
        }
    }
 
    cout << "YES" << endl;;
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<b;++i)

using namespace std;
int dp[105][6][6][6];
const int mod=1000000007;

//1=A,2=C,3=G,4=T
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i,j,k,l,m;
    int n;cin>>n;
    int a=1,g=3,c=2;
    FOR(i,1,5){
        FOR(j,1,5){
            FOR(k,1,5){
                if((i==1&&j==3&&k==2)||(i==1&&j==2&&k==3)||(i==3&&j==1&&k==2)) continue;
                dp[3][i][j][k]=1;
            }
                 
        }
    }
    FOR(i,4,101){
        FOR(j,1,5){
            FOR(k,1,5){
                FOR(l,1,5){
                    FOR(m,1,5){
                        if((k==a&&l==g&&m==c)||(k==a&&l==c&&m==g)||(k==g&&l==a&&m==c)||(j==a&&l==g&&m==c)||(j==a&&k==g&&m==c)) continue;
                        dp[i][k][l][m]+=dp[i-1][j][k][l];
                        dp[i][k][l][m]%=mod;
                    }
                }
            }
        }
    }
    int ans=0;
    FOR(i,1,5)
        FOR(j,1,5)
            FOR(k,1,5){
                ans+=dp[n][i][j][k];
                ans%=mod;
            }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 200000;
 
int main(){
    int N,M,K;
    long long A[MAX],B[MAX];
 
    cin >> N >> M >> K;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    for(int i = 0;i < M;i++){
        cin >> B[i];
    }
 
    long long sum = 0;
    int cnt = 0;
    int ai = 0;
    int bi = 0;
    int ans = 0;
 
    for(;ai < N;ai++){
        if(sum + A[ai] > K)break;
        sum += A[ai];
        cnt++;
    }
    ai--;
 
    while(ai >= -1){
        for(;bi < M;bi++){
            if(sum + B[bi] > K)break;
            sum += B[bi];
            cnt++;
        }
        ans = max(cnt,ans);
 
        if(ai < 0)break;
        sum -= A[ai];
        ai--;
        cnt--;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

class Cube{
    public:
    int f[6];
    Cube(){}
    void roll_z(){roll(1,2,4,3);}
    void roll_y(){roll(0,2,5,3);}
    void roll_x(){roll(0,1,5,4);}
    void roll(int i, int j, int k,int l){
        int t =f[i] ; f[i]= f[j] ;f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

int getRight( Cube c1, int f1, int f2){
    for (int i=0; i<6 ;i++){
        for(int j=0;j<4 ;j++){
            if (c1.f[0]==f1 && c1.f[1]==f2) return c1.f[2];
            c1.roll_z();
        }
        if (i%2==0) c1.roll_y();
        else c1.roll_x();
    }
    return -1;
}

int main(){
    Cube c;
    int f1,f2;
    
    for (int i=0; i<6;i++) cin >> c.f[i];
    int q; cin >> q;
    
    for (int i = 0; i<q ;i++){
        cin >> f1 >> f2;
        cout << getRight(c,f1,f2)<< endl;
    }
    
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int x0 = ri();
	int v0 = ri();
	int x1 = ri();
	int v1 = ri();
	int t = ri();
	puts(v0 > v1 && (int64_t) t * (v0 - v1) >= std::abs(x1 - x0) ? "YES" : "NO");
	return 0;
}


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

int main() {
    int r, c;
    cin >> r >> c;

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

    int total = 0;
    for (int i = 0; i < r; i++) {
        int row_sum = 0;
        for (int j = 0; j < c; j++) {
            int number;
            cin >> number;

            row_sum += number;
            col_sum[j] += number;
            total += number;
 
            cout << number << " ";
        }
        cout << row_sum << endl;
    }

    for (int j = 0; j < c; j++) {cout << col_sum[j] << " ";}
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

void Main(){
    ll n; cin >> n;
    
    // (i, 0) -> i
    // (i, 1) -> n + i
    UnionFind UF(2 * n); 

    rep(i, n-1){
        int a, b, w; cin >> a >> b >> w; a--; b--;
        if(w & 1){
            UF.unite(a, n + b);
            UF.unite(b, n + a);
        }else{
            UF.unite(a, b);
            UF.unite(n + a, n + b);
        }
    }

    vi ans(n, 1);

    rep(i, n){
        if(UF.same(i, 0)) ans[i] = 0;
        cout << ans[i] << endl;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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


int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int cnt = max(0, min(B,D)-max(A,C));
    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  while(int n = getInt()){
    vector<int> v(n);
    int ans = 0;
    REP(i,n){
      v[i] = getInt();
      REP(j,i){
	if(v[i] < v[j]) ans++;
      }
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e16; //10^9+7


int main(){
    int x, a, b;
    cin >> x >> a >> b;
    print((x - a) % b);
}

Measured memory_bytes: 256
program main
    implicit none
    integer x, y
    integer a, b

    read(*,*) x, y

    if (mod(y, 2) == 0) then
        a = 2*x - y/2
        b = y/2 - x
        if(a >= 0 .and. b >= 0) then
            write(*,*) "Yes"
        else
            write(*,*) "No"
        end if
    else
        write(*,*) "No"
    end if

end program


Measured memory_bytes: 2856
# AOJ 2881: Change of the Era Name
# Python3 2018.7.10 bal4u

# y << 9, m << 5, d 
LAST = (31<<9) + (5<<5) + 1		# H31.5.1

while True:
	a = input()
	if a == "#": break
	era, y, m, d = a.split()
	y, m, d = int(y), int(m), int(d)
	date = (y<<9) + (m<<5) + d
	if date >= LAST: print('?', y-30, m, d)
	else: print(era, y, m, d)


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n;
  string str;
  cin >> n;
  getline(cin,str);
  while(n--){
    str = "";
    getline(cin,str);
    string s = str;
    for(int a = 0 ; a < 100 ; a++ ){
      for(int b = 0 ; b < 26 ; b++){
	string t = "";
	for(int i = 0 ; i < str.size() ; i++){
	  for(int c = 0 ; c < 26 ; c++){
	    if(s[i] - 'a' == (a*c + b)%26){
	      t+=char(c + 'a');
	    }
	  }
	  if(s[i] - 'a' == -65)t+=' ';
	}
	if(t.find("that") != string::npos || t.find("this") != string::npos){
	  cout << t << endl;
	  goto N;
	}
      }
    }
  N:;
  }
}

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

int main() {
  ll n;
  string ans = "";
  cin >> n;
  while(n > 0) {
    ans = alpha[(n - 1) % 26] + ans;
    n = (n - 1) / 26;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640