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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

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

int a, b;
string s;

void input()
{
  cin >> a >> b >> s;
}

void solve()
{
  if(s.length() != a + b + 1)
  {
    cout << "No";
          return;
  }
  if(s[a] == '-')
    {
      REP(i, s.size())
      {
        if(a != i && isdigit(s[i]) == 0)
        {
          cout << "No";
          return;
        }
      }
    }
    else
    {
      cout << "No";
          return;
    }
    
    cout << "Yes";
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[222222];
long long d=1e9+7;
int main()
{
	int n;cin>>n;
	long long sum=0,he=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i]*he;
		he+=a[i];
		sum%=d;
		he%=d;
	} 
		
	
	cout<<sum;
	return 0;

}

Measured memory_bytes: 5172
MOD = 10**9 + 7
def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]
    d = []
    d.append(c[0])
    for i in range(1, n):
        if c[i] != d[len(d)-1]:
            d.append(c[i])
    lst = [-1]*(2*10**5+1)
    dp = [0]*len(d)
    dp[0] = 1
    lst[d[0]] = 0
    for i in range(1, len(d)):
        if lst[d[i]] == -1:
            lst[d[i]] = i
            dp[i] += dp[i-1]
        else:
            dp[i] += dp[i-1] + dp[lst[d[i]]]
            lst[d[i]] = i
        dp[i] %= MOD
    print(dp[len(d)-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 26012
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
void dfs(int i,vector<int> v[],vector<bool>& vis)
{
    vis[i]=1;
    for(int j=0;j<v[i].size();j++){
        int x = v[i][j];
        if(!vis[x]){
            dfs(x,v,vis);
        }
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    vector<bool> vis(n+1,0);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i,v,vis);
            ans++;
        }
    }
    cout<<ans-1;
}

int32_t main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 10736
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		for(int x = 1; x <= N; x++){
			if(N <= x * (x + 1) / 2){
				int diff = x * (x + 1) / 2 - N;
				for(int i = 1; i <= x; i++)
					if(i != diff) System.out.println(i);
				return;
			}
		}
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b,c;
	t = 1;
	while(t--) {
	 cin >> a >> b >> c;
	 cout << ((a + b) * c) / 2 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
a1, a2, a3 = map(int, input().split())
a4, a5, a6 = map(int, input().split())
a7, a8, a9 = map(int, input().split())

la = list()
la.append(a1)
la.append(a2)
la.append(a3)
la.append(a4)
la.append(a5)
la.append(a6)
la.append(a7)
la.append(a8)
la.append(a9)

N = int(input())

lb = list()
for i in range(N):
    lb.append(int(input()))

for i in range(N):
    for j in range(9):
        if lb[i] == la[j]:
            la[j] = 0

if la[0] + la[1] + la[2] == 0 or la[3] + la[4] + la[5] == 0 or la[6] + la[7] + la[8] == 0 or la[0] + la[3] + la[6] == 0 or la[1] + la[4] + la[7] == 0 or la[2] + la[5] + la[8] == 0 or la[0] + la[4] + la[8] == 0 or la[2] + la[4] + la[6] == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N,M = map(int,input().split())
A = []
B = []
C = []
D = []
for i in range(N):
    x,y = map(int,input().split())
    A.append(x)
    B.append(y)
for i in range(M):
    x,y = map(int,input().split())
    C.append(x)
    D.append(y)
k = 0
for i in range(N):
    g = 100000000000
    for j in range(M):
        t = abs(A[i]-C[j])+abs(B[i]-D[j])
        
        if t < g:
            k = j+1
            g = t
    print(k)

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

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

  int d[n];
  int i,j;
  int ans=0;
  
  for(i=0;i<n;i++){
    cin >> d[i];
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      ans=ans+d[i]*d[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d", $S);
$ans = 0;
for ($i = 1; $i <= intdiv($S, 3); $i++) {
    $amari = $S - $i * 3;
    $x = pascal($amari + $i - 1, $i - 1);
    $ans += $x;
    $ans %= MOD;
}
printf("%d", $ans);

function pascal($x, $y) {
    global $memo;
    if (isset($memo[$x][$y])) {
        return $memo[$x][$y];
    }
    if($y === 0 || $y === $x) {
        $tmp = 1;
        $memo[$x][$y] = $tmp;
        return $tmp;    
    } else {
        $tmp = pascal($x - 1, $y - 1) + pascal($x - 1, $y);
        $tmp %= MOD;
        $memo[$x][$y] = $tmp;
        return $tmp;
    }
}


Measured memory_bytes: 57544
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
g = [[] for i in range(n)]
cc = dict()
for i in range(n-1):
    a,b,c = inpl()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
    cc[(a,b)] = c
    cc[(b,a)] = c
q,k = inpl()
k -= 1
cost = [INF] * n
cost[k] = 0
def dfs(node,c):
    for next in g[node]:
        if cost[next] == INF:
            cost[next] = c + cc[(node,next)]
            dfs(next,cost[next])

dfs(k,0)
res = [0] * q
for i in range(q):
    x,y = inpl()
    x -= 1
    y -= 1
    res[i] = cost[x] + cost[y]
for z in res:
    print(z)


Measured memory_bytes: 152160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s,t,u;cin>>s>>t>>u;
	int a=1,b=0,c=0;
	char turn = s[0];
	while(!(turn == 'a' && a == s.size()) && !(turn == 'b' && b == t.size()) && !(turn == 'c' && c == u.size())){
		if(turn == 'a'){
			turn  = s[a];
			a++;
		}
		else if(turn == 'b'){
			turn = t[b];
			b++;
		}
		else{
			turn = u[c];
			c++;
		}
	}
	cout << char('A' + turn - 'a') << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,a,b,ans = 1;
    cin >> k >> a >> b;
    if (b > a && b - a > 2) {
        long long t = min(k,a-1);
        k -= t;
        ans += t;
        if (ans == a) {
            ans += (k/2) * (b-a);
            k %= 2;
        }
    }
    ans += k;
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(S: str):
    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
        return

    if len(S) < 26:
        res = sorted(list(set("zyxwvutsrqponmlkjihgfedcba")-set(S)))
        print(S+res[0])
    else:
        prev = None
        for i in range(25,-1,-1):
            if prev == None or prev < S[i]:
                prev = S[i]
                continue
            else:
                res = sorted(list(set("zyxwvutsrqponmlkjihgfedcba")-set(S[:i+1])))
                for s in res:
                    if s > S[i]:
                        print(S[:i]+s)
                        return
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repeat(i, n) for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
	ll N, K;
	cin >> N >> K;
	ll result = 0;

	ll n = N;
	while (n > 0) {
		result++;
		n /= K;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			char prev = '\0';
			
			HashSet<String> strs = new HashSet<>();
			for(int i = 0; i < N; i++) {
				final String str = sc.next();
				final char[] chs = str.toCharArray();
				
				if(strs.contains(str)) {
					System.out.println("No"); return;
				}else if(prev == '\0' || prev == chs[0]) {
					prev = chs[chs.length - 1];
					strs.add(str);
				}else {
					System.out.println("No"); return;
				}
			}
			
			System.out.println("Yes");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22740
#include<stdio.h>

int binarySearch(int );

int S[100000],n;


int main(){

  int i,j,q,T[50000],C;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&T[i]);
      if((binarySearch(T[i]))==0)
      C++;
    }
    printf("%d\n",C);
    return 0;
}

int binarySearch(int key){

  int left=0,right,mid;
  right=n;
  while(left<right){
    mid=(left+right)/2;
      if(S[mid]==key)
	return 0;
      else if (key<S[mid])
	right=mid;
      else left=mid+1;
  }
  return 1;
}
    
    

Measured memory_bytes: 1184
#encoding:utf-8

N = int(input())
A,B = map(int, input().split())
P = [int(i) for i in input().split()]

P.sort()
a_count = len([i for i in P if i<= A])
b_count = len([i for i in P if A < i <= B])
c_count = len([i for i in P if B < i])

print(min(a_count,b_count,c_count))


Measured memory_bytes: 3060
/*
filename:4_B-Binary_Search
created at 16.9.2015 by charis
last edited at 16.9.2015 by charis
*/

#include<iostream>
using namespace std;

int binarySearch(int n, int A[], int key){
	int left = 0, right = n;
	while(left < right){
		int mid = (left + right)/2 ;
		if (A[mid] == key) return 1;
		else if (A[mid] < key) left = mid+1 ;
		else right = mid ;
	}
	return 0;
}

int main(){
	int n, q, key, C=0;
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++){
		cin >> A[i];
	}
	
	cin >> q;
	for(int j=0; j<q; j++){
		cin >> key ;
		if ( binarySearch(n, A, key) ) C++;
	}
	
	cout << C << endl;
	
	return 0;
}

Measured memory_bytes: 1552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

ll H,W;

bool movable(ll sx,ll sy,ll gx,ll gy){
  if(gx>=W||gy>=H) return false;
  
  return true;
}

int main()
{
  cin>>H>>W;
  vector<vector<ll>> a(H,vector<ll>(W)); rep(i,H) rep(j,W) cin>>a[i][j];
  
  vector<vector<ll>> vec(0);
  rep(y,H){
    rep(x,W){
      if(a[y][x]%2==0) continue;
      if(movable(x,y,x+1,y)&&a[y][x+1]%2==1){
        a[y][x+1]++;
        vec.push_back({y,x,y,x+1});
        continue;
      }
      if(movable(x,y,x,y+1)&&a[y+1][x]%2==1){
        a[y+1][x]++;
        vec.push_back({y,x,y+1,x});
        continue;
      }
      if(movable(x,y,x+1,y)){
        a[y][x+1]++;
        vec.push_back({y,x,y,x+1});
        continue;
      }
      if(movable(x,y,x,y+1)){
        a[y+1][x]++;
        vec.push_back({y,x,y+1,x});
        continue;
      }
    }
  }
  
  cout<<vec.size()<<endl;
  for(auto p:vec){
    rep(i,4){
      if(i!=0) cout<<" ";
      cout<<p[i]+1;
    }
    cout<<endl;
  }
  return 0;
}


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

int main() {
string N;
cin >> N;
if(N.at(0) == N.at(1) && N.at(1) == N.at(2)) cout << "Yes" << endl;
else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)) cout << "Yes" << endl;
else cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int x;
	cin>>x;
	if(x<1200) puts("ABC");
	else puts("ARC");
	return 0;
}



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

int main(){
    int n,b;
    scanf("%d",&n);
    scanf("%d",&b);
    int sc = n*b;
    int li = 2*(n+b);
    printf("%d %d\n",sc,li);
    return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;
#define ll long long int


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);


	char a;
	cin >> a;
	if ('A' <= a && a <= 'Z') cout << 'A' << endl;
	else cout << 'a' << endl;




	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		int k = int.Parse(Console.ReadLine());
		string s =Console.ReadLine();
		
		if(s.Length<=k){
			Console.WriteLine(s);
		}else{
			Console.WriteLine(s.Substring(0,k) + "...");
		}
		
	}
}

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

int main(){
    l n, d, t1, t2, sum =0;
    vector<l> xi, yi;
    cin >> n >> d;
    for(auto i=0;i<n;i++){
        cin >> t1 >> t2;
        xi.push_back(t1);
        yi.push_back(t2);
    }
    for(auto i=0;i<n;i++){
        if(sqrt(pow(xi.at(i),2)+pow(yi.at(i),2))<=d)sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 6644
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


#define int ll

int n1, n2;
int dp[2222][2222];
int s[2222],t[2222];
int f(int* s, int* t)
{


    for (int i = 0; i <= n1; i++) {
        for (int j = 0; j <= n2; j++) {
            dp[i][j] = 0;
        }
    }

    for (int i = 1; i <= n1; i++) {

        for (int j = 1; j <= n2; j++) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j];
            else
                dp[i][j] = dp[i][j - 1] + dp[i - 1][j] -
                           dp[i - 1][j - 1];
            dp[i][j] = mod(dp[i][j], MOD);
        }
    }

    return mod(dp[n1][n2], MOD);;
}

class ECommonSubsequence {
public:
void solve(std::istream& cin, std::ostream& cout) {
    cin >> n1 >> n2;
    _for(i,n1)cin >> s[i];
    _for(i,n2)cin >> t[i];
    cout << f(s,t) + 1<< endl;
}
};


#undef int
int main() {
	ECommonSubsequence solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 35072
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.x<<" "<<p.y<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const double PI = 4*atan(1.0);

struct C {
    ll x, y;
    C() {}
    C(ll x, ll y) : x(x), y(y) {}
    C operator-(C p) const {return C(x-p.x, y-p.y);}
    ll det(C p) const {return x*p.y-y*p.x;} // ??????
    bool operator<(const C& another) const {
        if (x != another.x) return x < another.x;
        return y < another.y;
    }
};

//????§???¢?????¢???
ll area(const vector<C>& ps)
{
    ll A = 0;
    rep(i,ps.size()){
        A += ps[i].det(ps[(i+1) % ps.size()]);
    }
    return A;
}

vector<ll> convex_hull(vector<C> ps)
{
    int n = ps.size(), k = 0;
    vector<C> ch(n);
    vector<ll> s(n+1);
    //?????´??????
    for (int i = 0; i < n; ch[k++] = ps[i++]){
        s[i+1] = s[i];
        while (k >= 2 && (ch[k-1]-ch[k-2]).det(ps[i]-ch[k-1]) < 0){
            if(k >= 3){
                vector<C> tri = {ch[0],ch[k-2],ch[k-1]};
                s[i+1] -= area(tri);
            }
            k--;
        }
        if(k >= 2){
            vector<C> tri = {ch[0],ch[k-1],ps[i]};
            s[i+1] += area(tri);
        }
    }
    return s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<C> vec(n);
    rep(i,n){
        int u,v;
        cin >> u >> v;
        vec[i] = C(u,v);
    }
    sort(all(vec));
    vector<ll> ld = convex_hull(vec);
    // svec(ld);
    rep(i,len(vec)){
        vec[i] = C(vec[i].x,-vec[i].y);
    }
    vector<ll> lu = convex_hull(vec);
    rep(i,len(vec)){
        vec[i] = C(-vec[i].x,vec[i].y);
    }
    // svec(vec);
    sort(all(vec));
    vector<ll> ru = convex_hull(vec);
    rep(i,len(vec)){
        vec[i] = C(vec[i].x,-vec[i].y);
    }
    vector<ll> rd = convex_hull(vec);
    rep(i,len(vec)){
        vec[i] = C(-vec[i].x,vec[i].y);
    }
    sort(all(vec));
    ll ans = ld[n] + lu[n] + rd[0] + ru[0];
    rep(i,n-1){
        if(vec[i].x == vec[i+1].x){
            continue;
        }
        cmn(ans,ld[i+1]+lu[i+1]+rd[n-1-i]+ru[n-1-i]);
    }
    cout << (ans+1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 10500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 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);
}*/

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

	string s;
	cin >> s;

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}

	if (26 == (int)s.size()) {
		// 絶対文字数減る
		// 後ろから
		vector<char> c;
		int cnt = 1;
		for (int i = (int)s.size() - 1; i > 0; i--) {
			c.push_back(s[i]);
			if (s[i] > s[i - 1]) {
				rep(j, cnt) {
					if (s[i - 1] > c[j]) continue;
					s[i - 1] = c[j];
					rep(j, i) {
						cout << s[j];
					}
					break;
				}
				cout << endl;
				break;
			}
			cnt++;
		}

	}
	else {
		vector<int> cNum(26, 0);
		rep(i, (int)s.size()) {
			cNum[s[i] - 'a']++;
		}
		cout << s;
		rep(i, 26) {
			if (cNum[i] == 0) {
				cout << (char)(i + 'a') << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0; i<k; i++){
        if(a>=b){
            b*=2;
        }else if(b>=c){
            c*=2;
        }
    }
    
    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

long long ans = 1;
int n;
map<int, int> f;

void factorization(int n){
	for(int i = 2; i <= n; ++i){
		while(n % i == 0){
			f[i]++;
			n /= i;
		}
	}
}

int main(){
	cin >> n;
	
	for(int i = 1; i <= n; ++i) factorization(i);
	for(auto itr = f.begin(); itr != f.end(); itr++){
		ans *= (itr->second+1);
		ans %= 1000000007;
	}
	cout << ans << endl;
}

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

using namespace std;

int L;
char sir[200009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s", sir), L = strlen (sir);
for (int i=0; i<L; i++)
    if (sir[i] == '?')
        sir[i] = 'D';
printf ("%s\n", sir);
return 0;
}


Measured memory_bytes: 3848
import sys
input = sys.stdin.readline


N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(M)]

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

union = UnionFind(N)

for x, y, z in XYZ:
    union.Unite(x, y)

A = set()
for i in range(1, N+1):
    A.add(union.Find_Root(i))

print(len(A))

Measured memory_bytes: 37944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

int main() {
  lint X,Y,Z;
  cin >> X >> Y >> Z;
  X -= Z;
  cout << X/(Y+Z) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
//#include<unordered_map>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 100005;
#define rep( i , a , b ) for ( int i = a ; i < b ; ++ i )
#define CLR(a) memset(a,0,sizeof a)
#define repf( i , a , b ) for ( int i = a ; i <= b ; ++ i )
template <class T>
void in(T& x) {
	static char ch; static bool neg;
	for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar());
	for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar());
	x = neg ? -x : x;
}



int main()
{
	//freopen("in.txt", "r", stdin);
	ll a, b, c;
	in(a); in(b); in(c);
	cout << max(0ll,c - (a - b)) << endl;




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pll pair < ll , ll >
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ld long double
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
ll M = 1e9 + 7;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main()
{

    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    ll l=0 , r=0;
    for( int i = 0; i < k; i++)
    {
        l+=i;
        r+=n-i;
    }
    ans+=(r-l)+1;
    for( int i = k; i <= n; i++)
    {
        l+=i;
        r+=(n-i);
        ans+=((r-l))%M+1;
        ans%=M;
    }
    cout << ans;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tet"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e18;
typedef pair<ll,ll> LL;

ll n,i,cur = 1,a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    for (i = 1;i <= n;i++){
        cin>>a[i];
    }
    sort(a + 1,a + n + 1);
    for (i = 1;i <= n;i++){
        //cout<<inf/cur<<"\n";
        if (cur == 0){
            cout<<0; return 0;
        }
        if (inf/cur < a[i]){
            cout<<-1; return 0;
        }
        cur *= a[i];
    }
    cout<<cur;
}


Measured memory_bytes: 4448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

int a[5];
int ans = 10000;
int func2(vector<int>& v){
  int id = 0, wt = 0;
  for(int i = 0; ; i++){
    if(i % 10 == 0 && wt <= 0){
      wt = a[v[id]];
      id++;
      if(id >= 5) return i + wt;
    }
    wt--;
  }
}

void func(vector<int>& v){
  if(v.size() == 5){
    //for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << endl;
    ans = min(func2(v), ans);
    return;
  }
  for(int i = 0; i < 5; i++){
    int j;
    for(j = 0; j < v.size(); j++){
      if(v[j] == i) break;
    }
    if(j != v.size()) continue;
    v.push_back(i);
    func(v);
    v.pop_back();
  }
}

void solve(){
  for(int i = 0; i < 5; i++) cin >> a[i];
  vector<int> v;
  func(v);
  cout << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
P=10**9+7
ans=0
BIN=[0]*N
for h in range(N):
    BIN[h]=bin(A[h])[2:].zfill(60)

for i in range(60):
    inc=0
    one=0
    zero=0
    for j in range(N):
        if BIN[j][59-i]=="0":
            zero+=1
        else:
            one+=1
    ans+=zero*one*2**i
print(ans%P)

Measured memory_bytes: 135440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int N;
    cin>>N;
    vl A(N);
    vl gl(N);
    vl gr(N);
    F0R(i,N){
        cin>>A[i];
    }
    ll g=1;
    F0R(i,N){
        if(i==0){
            gl[i]=g;
            g=A[i];
        }else{
            gl[i]=g;
            g=__gcd(g,A[i]);
        }
    }
    g=1;
    for(int i=N-1;i>=0;i--){
        if(i==N-1){
            gr[i]=g;
            g=A[i];
        }else{
            gr[i]=g;
            g=__gcd(A[i],g);
        }
    }
    ll ans=-1ll;
    F0R(i,N){
        if(i==0){
            ans=max(ans,gr[i]);
        }else if(i==N-1){
            ans=max(ans,gl[i]);
        }else{
            ans=max(ans,__gcd(gr[i],gl[i]));
        }
    }
    out(ans);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 2560
import re
S = input()
if not S[0] == 'A':
    print('WA')
elif len(S) > 4 and S[2:-1].count('C') != 1:
    print('WA')
elif len(S) == 4 and S[2:].count('C') != 1:
    print('WA')
elif len(re.findall('[A-Z]', S)) != 2:
    print('WA')
else:
    print('AC')

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll MAX = 300000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(ll n, ll k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll FAC(ll n){
  return fac[n];
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

  COMinit();

  ll N,A,B,C;
  cin>>N>>A>>B>>C;
  ll AN[N+1], BN[N+1], ABNinv[2*N+1];
  AN[0]=1;BN[0]=1;ABNinv[0]=modinv(1,MOD)%MOD;
  for(int i=1;i<=N;i++){
    AN[i]=AN[i-1]*A%MOD;
    BN[i]=BN[i-1]*B%MOD;
  }
  ll ABinv=modinv(A+B,MOD)%MOD;
  for(int i=1;i<2*N;i++){
    ABNinv[i]=ABNinv[i-1]*ABinv%MOD;
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    ans+=AN[N]*BN[i]%MOD*COM(N+i-1,N-1)%MOD*ABNinv[i+N]%MOD*(N+i)%MOD*100%MOD*(modinv(100-C,MOD))%MOD;
    ans%=MOD;
    ans+=BN[N]*AN[i]%MOD*COM(N+i-1,N-1)%MOD*ABNinv[i+N]%MOD*(N+i)%MOD*100%MOD*(modinv(100-C,MOD))%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10368
N,M = map(int,input().split())
S = [[int(i)-1 for i in input().split()] for _ in range(M)]
P = [int(i) for i in input().split()]

ans = 0
for i in range(1<<N):
    for j in range(M):
        cnt = 0
        for s in S[j][1:]:
            if i >> s & 1: cnt += 1
        if cnt%2 != P[j]: break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
/**
 * 以下の検証用コード
 * https://atcoder.jp/contests/abc126/submissions/8719236
 */

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 10;


struct edge{
  int to, cost;
};
vector<vector<edge>> G(100005);
vector<bool> seen(100005, false);
vector<int> ans(100005, 0);
vector<int> sum1(100005, 0);

void dfs(int v, int sum){
  for(int i=0;i<G[v].size();i++){
    edge e = G[v][i];
    if(seen[e.to]) continue;
    seen[e.to] = true;
    sum1[e.to] = sum1[v] + e.cost;
    ans[e.to] = sum1[e.to] % 2;
    dfs(e.to, sum);
  }

  return;
}


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  rep(i, N-1){
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    G[x].push_back(edge{y, z});
    G[y].push_back(edge{x, z});
  }
  seen[0] = true;
  dfs(0, 0);
  rep(i, N){
    cout << ans[i] << endl;
  }
}


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

int main() {
  int N, K;
  scanf("%d%d", &N, &K);

  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans <= K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }

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


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<random>
using namespace std;


int main()
{
	int N;
	cin >> N;
	if (N == 1) {
		cout << "NO" << endl;
		return 0;
	}
	int i = 0;
	int count_A = 0;
	int A = 0;
	string curr;
	vector<int> m(N); //1 -> A    0 -> Un
	while (i < N) {
		cin >> curr;
		if (curr == "A") m[i] = 1;
		else m[i] = 0;
		++i;
	}
	if (m[0] == 0 || m[N - 1] == 1) {
		cout << "NO" << endl;
		return 0;
	}
	for (int i = 0; i < N; ++i) {
		if (count_A < 0) {
			cout << "NO" << endl;
			return 0;
		}

		if (m[i] == 1) {
			++count_A;
		}
		if (m[i] == 0) {
			--count_A;
		}
	}
	
	if (count_A == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main() {
        ios_base:: sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s;
        cin >> s;
        for(int i = 0; (i + 1) < s.length(); i++) {
                if(s[i] == s[i + 1]) {
                        cout << "Bad";
                        return 0;
                }
        }
        cout << "Good";
        return 0;
}

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

int main() {

    int a;
    int b;
    int ab;

    cin >> a >> b;

    ab = a * b;
    
    if (ab % 2 == 0){
        cout <<  "Even" << endl;
    }
    else {
        cout <<  "Odd" << endl;
    }

    return 0;

}

Measured memory_bytes: 3640
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  rank <- VM.replicate n (0 :: Int)

  let getRoot !i xs = do
        !j <- VM.read assocs i
        if i == j
          then return (i,xs)
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify !i !j = do
        (!i',xs) <- getRoot i []
        (!j',ys) <- getRoot j []
        if i' == j'
          then return 0
          else do
          !ri <- VM.read rank i'
          !rj <- VM.read rank j'
          !k <- case compare ri rj of
                  EQ -> do VM.write rank i' (ri + 1)
                           VM.write assocs j' i'
                           return i'
                  LT -> do VM.write assocs i' j'
                           return j'
                  GT -> do VM.write assocs j' i'
                           return i'
          forM_ xs (\l -> VM.write assocs l k)
          forM_ ys (\l -> VM.write assocs l k)
          !n1 <- VM.read numberOfElements i'
          !n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

readIntPair :: IO (Int, Int)
readIntPair = do
  [a,b] <- BS.words <$> BS.getLine
  case (BS.readInt a, BS.readInt b) of
    (Just (a', _), Just (b', _)) -> return (a',b')

main = do
  (n,m) <- readIntPair -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    (a,b) <- readIntPair
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 6908
H, W = map(int, input().split())
mod = 10 ** 9 + 7
A = []
for _ in range(H):
    a = input()
    A.append(a)

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i + 1 < H and A[i+1][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
        if j + 1 < W and A[i][j+1] == ".":
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print(dp[-1][-1])

Measured memory_bytes: 53488
#include <cstdio>
#include <cctype>
#define reg register
#define int long long
using namespace std;
const int MaxN=200001;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[MaxN],f[MaxN],g[MaxN];
int n;
inline int getsum(int l,int r)
{
	return f[r]-f[l-1];
}
inline int getxor(int l,int r)
{
	return g[r]^g[l-1];
}
signed main(void)
{
	reg int ans=0;
	rd(n);
	for(int i=1;i<=n;++i)
	{
		rd(a[i]);f[i]=f[i-1]+a[i];g[i]=g[i-1]^a[i];
	}
	reg int l=1;
	for(int r=1;r<=n;++r)
	{
		while(getsum(l,r)!=getxor(l,r))
			++l;
		ans+=r-l+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4864
#include    <iostream>

using namespace std;

int main() {
    while(1) {
        int a, b;
        char op;
        cin >> a >> op >> b;

        if(op == '?') break;
        switch(op) {
            case '+':   cout << a+b << endl; break;
            case '-':   cout << a-b << endl; break;
            case '*':   cout << a*b << endl; break;
            case '/':   cout << a/b << endl; break;
            case '%':   cout << a%b << endl; break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    string s;
    cin >> n >> s;
    // 最も手前に(をつける
    // 最も後ろに)をつける
    // cout << '(' + 0 << endl; // 40
    // cout << ')' + 0 << endl; // 41
    // start: 頭に(をつける必要のある個数
    // end: 尻尾に)をつける必要のある個数
    ll start=0 ,end=0;
    rep(i,n){
        if(s.at(i)=='(') end++;
        if(end!=0 && s.at(i)==')') end--;
    }
    for(ll i=n-1; i>=0; i--){
        if(s.at(i)==')') start++;
        if(start!=0 && s.at(i)=='(') start--;
    }
    string res = "";
    rep(i,start) res += "(";
    res += s;
    rep(i,end) res += ")";
    cout << res << endl;
}

Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
	char s;
	cin >> s;

	if(s>='A'&&s<='Z')cout << "A" << endl;
	else cout << "a" << endl;
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3584