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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << '\n';
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("milkvisits.in","r",stdin );
#define outF freopen("milkvisits.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define lp(i , n) for(int x = i ; x < n ; x ++)
#define ll long long
#define read(arr , x , n) for(int i = x ; i < n ; i ++ )cin >> arr[i];
const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const ll N = 2e5 + 5  , oo = 1e9 + 1  , M = 2000002, mod = 1e9 + 7 , K = 12;


//                                                +_+
int32_t main(){
    // inF;outF;
    fastio;
    // Dont Forget memset
    double a , b , c ;
    cin >> a >> b >> c ;

    cout << (a / c <= b ? "Yes" : "No");
}


Measured memory_bytes: 3732
n = int(input())
A = [int(i) for i in input().split()]
center = n//2
ans = [0 for i in range(n)]
haba = 1
hugou = n%2 == 1

for a in A:
    ans[center] = a
    if hugou:
        center += haba
    else:
        center -= haba
    haba += 1
    hugou = not(hugou)
for i in ans[:-1]:
    print(i,end = " ")
print(ans[-1])

Measured memory_bytes: 26360
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }

    if (n != 1)res.push_back(make_pair(n, 1)); 
    return res;
}

int main() {
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);
    auto v = prime_factorize(g);
    for(auto e: v)  {
        DEBUG(e.first);
        DEBUG(e.second);
    }
    cout << v.size() + 1 << endl;
}


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

#define ll long long 
#define inf 1e17
using namespace std;

ll dp[3010][3010],play[3010][3010];
string s,t;


void solve(int i,int j,string &ans)
{
	if(i<=0 || j<=0)return ;
	
	if(play[i][j]==2)
	{
		solve(i-1,j-1,ans);
		ans+=s[i-1];
	}
	else if(play[i][j]==1)
	{
		solve(i-1,j,ans);
	}
	else solve(i,j-1,ans);
	
}




int main()
{
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for(int i=0;i<=n;i++)
	{
		dp[i][0]=0;
	}
	for(int j=0;j<=m;j++){
			dp[0][j]=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
				play[i][j]=2;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				if(dp[i][j]==dp[i-1][j])
				{
					play[i][j]=1;
				}
				else 
				play[i][j]=0;
			}
		}
	}
	string ans;
	solve(n,m,ans);
	cout<<ans<<endl;
	
}

Measured memory_bytes: 141696
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayDeque;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        double tan = 360.0 * H / 12 + 0.5 * M;
        double tyo = 360.0 * M / 60;
        double c = Math.abs(tan - tyo);
        if(c>180){
            c = 360 - c;
        }
        double C = A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(c));
        System.out.println(Math.sqrt(C));
    }
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int n;
    cin>>n;
    rep(i,3)
    {
        if(n%10==7)
        {
            cout<<"Yes\n";
            return 0;
        }
        else
        {
            n/=10;
        }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,ans=0;
  cin>>N;
  
  if(N%10==0) ans+=9;
  while(N>=10){
    ans+=N%10;
    N=(N-N%10)/10;
  }
  
  co(ans+N);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

struct SAT
{
	int n, cnt, tim, top, sta[MAXN], dfn[MAXN], low[MAXN], scc[MAXN];
	vector <int> adj[MAXN];

	inline void Init(int m)
	{
		n = m, tim = cnt = 0;
		for (int i = 1; i <= n << 1; i ++)
			dfn[i] = scc[i] = 0, adj[i].clear();
	}

	inline void Addedge(int x, int y)
	{
		adj[x].pb(y), adj[y > n ? y - n : y + n].pb(x > n ? x - n : x + n);
	}

	inline void Dfs(int x)
	{
		int k = 0;
		dfn[sta[++ top] = x] = low[x] = ++ tim;
		for (auto y : adj[x])
			if (!dfn[y])
				Dfs(y), low[x] = min(low[x], low[y]);
			else if (!scc[y])
				low[x] = min(low[x], dfn[y]);
		if (dfn[x] == low[x])
			for (cnt ++; k ^ x; scc[k = sta[top --]] = cnt);
	}

	inline bool Solve()
	{
		for (int i = 1; i <= n << 1; i ++)
			if (!dfn[i])
				Dfs(i);
		for (int i = 1; i <= n; i ++)
			if (scc[i] == scc[i + n])
				return false;
		return true;
	}
} sat;

int n, m, x[MAXN], p[MAXN], idx[MAXN];

inline void Build(int x, int l, int r)
{
	idx[x] = ++ m;
	if (l == r)
		return ;
	int mid = l + r >> 1;
	Build(x << 1, l, mid), Build(x << 1 | 1, mid + 1, r);
}

inline void Addedge(int x, int l, int r)
{
	if (l == r)
		return sat.Addedge(idx[x], p[l] + m);
	int mid = l + r >> 1;
	Addedge(x << 1, l, mid), Addedge(x << 1 | 1, mid + 1, r);
	sat.Addedge(idx[x], idx[x << 1]), sat.Addedge(idx[x], idx[x << 1 | 1]);
}

inline void Addedge(int x, int l, int r, int ql, int qr, int p)
{
	if (l == ql && r == qr)
		return sat.Addedge(p, idx[x]);
	int mid = l + r >> 1;
	if (qr <= mid)
		return Addedge(x << 1, l, mid, ql, qr, p);
	if (ql > mid)
		return Addedge(x << 1 | 1, mid + 1, r, ql, qr, p);
	return Addedge(x << 1, l, mid, ql, mid, p), Addedge(x << 1 | 1, mid + 1, r, mid + 1, qr, p);
}

inline bool Chk(int lim)
{
	sat.Init(m);
	Addedge(1, 1, n << 1);
	for (int i = 1; i <= n << 1; i += 2)
		sat.Addedge(i, i + 1 + m), sat.Addedge(i + m + 1, i);
	for (int i = 1, j = 1; i <= n << 1; i ++)
	{
		for (; j <= n << 1 && x[p[j]] - x[p[i]] < lim; j ++);
		if (i + 1 < j)
			Addedge(1, 1, n << 1, i + 1, j - 1, p[i]);
	}
	return sat.Solve();
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n << 1; i ++)
		x[++ m] = Read(), p[m] = m;
	sort(p + 1, p + m + 1, [&](int a, int b) { return x[a] < x[b]; });
	Build(1, 1, m);
	int l = 1, r = 1e9, ret = 0;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if (Chk(mid))
			ret = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	return printf("%d\n", ret), 0;
}


Measured memory_bytes: 21376
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A, B;
		int tate, yoko;

		A = scan.nextInt();
		B = scan.nextInt();

		tate = A - 1;
		yoko = B - 1;

		System.out.println(tate * yoko);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27076
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        r = 0
        for k in range(D):
            r += (X[i][k] - X[j][k]) ** 2
        if r ** 0.5 % 1 == 0:
            count += 1
print(count)


Measured memory_bytes: 3060
main=do
 n<-readLn
 a<-map (\x->mod(read x)4).words<$>getLine
 putStrLn(f(sum[1|x<-a,x==0])(sum[1|x<-a,x==2])n) 
  where f n4 n2 na = if n2==0 then(if(quot na 2)>n4 then"No"else"Yes")else(if(quot(na-n2+1)2)>n4 then"No"else"Yes")

Measured memory_bytes: 33148
import time
import collections
import scipy.misc

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

N, M = map(int, input().split())
t_strt = time.time() 

factors = collections.Counter(prime_decomposition(M))
t_elps = time.time()
#print(f"{t_elps - t_strt} [sec]")
num_pattern = 1;

for exponent in factors.values():
    tmp_num_pattern = scipy.misc.comb(exponent + N -1, N-1, exact = True) 
    num_pattern = num_pattern * int(tmp_num_pattern)
    
print(num_pattern%(10**9+7))

Measured memory_bytes: 25584
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<ll> A(n), B(n);
  rep(i,n) std::cin >> A[i] >> B[i];
  std::sort( all(A) );
  std::sort( all(B) );

  ll xmin = (n%2==0) ? A[n/2-1]+A[n/2] : A[n/2];
  ll xmax = (n%2==0) ? B[n/2-1]+B[n/2] : B[n/2];
  std::cout << (xmax - xmin)+1 << std::endl;
  return 0;
}



Measured memory_bytes: 6348
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()

    nr = 0
    ng = 0
    nb = 0
    for s in S:
        if s == "R":
            nr += 1
        elif s == "G":
            ng += 1
        else:
            nb += 1

    ans = nr * ng * nb
    for left in range(N - 2):
        for center in range(left + 1, N - 1):
            right = center + (center - left)
            if right < N:
                if (
                    S[right] != S[left]
                    and S[left] != S[center]
                    and S[center] != S[right]
                ):
                    ans -= 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9248
n = int(input())
ans = 0

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def cnt(n):
    count = 1
    while n>=count:
        n -= count
        count+=1
    return count-1

if n==1:
    print(0)
    exit()

lst = factorization(n)
for i in lst:
    ans += cnt(i[1])

print(ans)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;

int main()
{
  ll N,H;
  cin >> N >> H;
  vector<ll> A(N);
  vector<ll> B(N);
  ll sum=0;
  ll amax=0;
  REP(i, N){
    cin >> A[i] >> B[i];
    amax=max(amax,A[i]);
  }
  sort(ALL(A));
  reverse(ALL(A));
  sort(ALL(B));
  reverse(ALL(B));
  ll cnt = 0;
  REP(i,N){
    if(amax<B[i]){
      sum+=B[i];
      cnt++;
    }
  }
  if(sum<H){
    if((H-sum)%A[0]==0){
      cout << cnt+(H-sum)/A[0] << endl;
    }else{
      cout << cnt+(H-sum)/A[0]+1 << endl;
    }
  }else{
    ll sum2=0;
    REP(i,N){
      sum2+=B[i];
      if(sum2>=H){
        cout << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x, y;
    x.resize(N+1);
    y.resize(M+1);
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    for(int i=0;i<M;i++){
        cin >> y[i];
    }
    x[N] = X; y[M] = Y;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x[N] < y[0]){
        cout << "No War\n";
    }else{
        cout << "War\n";
    }
    return 0;
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    ll tmp=min(n,m/2);
    ans=tmp;
    m-=tmp*2;
    if(m>0)ans+=m/4;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int N;
    cin >> N;
    int d = N / 10;
    int o = N % 10;
    cout << ((d == 9 || o == 9) ? "Yes":"No");
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstring>

#define fin stdin
#define fout stdout

#define MOD (1000 * 1000 * 1000 + 7)

int a[409], b[409];
int d[409][409];
int put[409];

inline void calc(int a, int b, int c){
    memset(put, 0, sizeof put);
    for(int i = a; i <= b; i ++){
        int s = 1;
        for(int j = 0; j <= c; j ++){
            put[j] += s;
            if(put[j] >= MOD)
                put[j] -= MOD;
            s = (1LL * s * i) % MOD;
        }
    }
}

int main(){
    int n, c;
    fscanf(fin, "%d%d", &n, &c);

    for(int i = 1; i <= n; i ++)
        fscanf(fin, "%d", &a[i]);
    for(int i = 1; i <= n; i ++)
        fscanf(fin, "%d", &b[i]);

    calc(a[1], b[1], c);
    for(int i = 0; i <= c; i ++)
        d[1][i]=put[i];

    for(int i = 2; i <= n; i ++){
        calc(a[i], b[i], c);
        for(int j = 0; j <= c; j ++)
            for(int p = 0; p <= j; p++)
                d[i][j] = (d[i][j] + 1LL * d[i-1][p] * put[j-p]) % MOD;
    }

    /*for(int i = 1; i <= n; i ++){
        for(int j = 0; j <= c; j ++)
            fprintf(fout, "%d ", d[i][j]);
        fprintf(fout, "\n");
    }*/

    fprintf(fout, "%d\n", d[n][c]);

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  vector<vector<int>> H(h,vector<int>(w)),W(h,vector<int>(w));
  rep(i,h) cin >> s[i];
  
  rep(i,h){
    int pos = 0;
    int num = 0;
    rep(j,w){
      char c = s[i][j];
      if(c=='#'){
        for(int k = pos; k < j;k++){
          W[i][k] = num;
        }
        num = 0;
        pos = j+1;
      }else if(j == w-1){
        num++;
        for(int k = pos; k <= j;k++){
          W[i][k] = num;
        }        
      }else{
        num++;
      }
    }
  }
  rep(j,w){
    int pos = 0;
    int num = 0;
    rep(i,h){
      char c = s[i][j];
      if(c=='#'){
        for(int k = pos; k < i;k++){
          H[k][j] = num;
        }
        num = 0;
        pos = i+1;
      }else if(i == h-1){
        num++;
        for(int k = pos; k <= i;k++){
          H[k][j] = num;
        }        
      }else{
        num++;
      }
    }
  }
  
//  rep(i,h){
//    cout << endl;
//    rep(j,w){
//      cout << W[i][j];
//    }
//  }
  
//  rep(i,h){
//    cout << endl;
//    rep(j,w){
//      cout << H[i][j];
//    }
//  }
  
  int ans = 0;
  rep(i,h) rep(j,w) chmax(ans,H[i][j]+W[i][j]);
  
  cout << ans-1 << endl;

  return 0;
}

Measured memory_bytes: 35712
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int n, m, x; cin >> n >> m >> x;
    vvint a(n, vint(m));
    vint c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = INT_MAX;
    rep(bit, 1 << n) {
        vint rikai(m, 0);
        int cost = 0;
        rep(i, n) {
            if(bit & 1 << i) {
                rep(j, m) {
                    rikai[j] += a[i][j];
                }
                cost += c[i];
            }
        }
        int flag = 1;
        rfor(r, rikai) flag &= r >= x;
        if(flag) chmin(ans, cost);
    }
    if(ans == INT_MAX) ans = -1;

    println(ans);

    return 0;
}


Measured memory_bytes: 3632
n = int(input())

data = []
data.append([0, 0, 0])
for i in range(n):
    t, x, y = map(int,  input().split())
    data.append([t, x, y])

for i in range(1, n + 1):
    dis = abs(data[i][1] - data[i - 1][1]) + abs(data[i][2] - data[i- 1][2])
    dif = data[i][0] - data[i - 1][0]
    if (dif % 2 != dis % 2 or dis > dif):
        print("No")
        exit() 

print("Yes")

Measured memory_bytes: 19528
import itertools
n=int(input())
p,q=[tuple(map(int,input().split())) for i in (1,1)]
j=itertools.permutations
l=list(j(range(1,n+1)))

for i,s in enumerate(l):
  if s==p:a=i
  if s==q:b=i
print(abs(a-b))

Measured memory_bytes: 8052
n = input()
s = input()
lcnt = 0
rcnt = 0
for i in s:
  if i == '(':
    rcnt+=1
  else :
    if rcnt == 0:
      lcnt += 1
    else:
      rcnt -= 1
for i in range(lcnt):
  s = '(' + s
for i in range(rcnt):
  s = s + ')'
print(s)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];

    ll cnt = 0;
    REP(i,1,n-1){
        if((a[i] > a[i-1] && a[i] < a[i+1]) || (a[i] < a[i-1] && a[i] > a[i+1]))cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 2e6 + 10;
const int K = (int) 1e7 + 10;
const int mod1 = (int) 1e9 + 7;
const int mod2 = (int) 1e9 + 9;
const int T = (int) 200017;

int n;
string st;
pii p[N];

void add(pii &x, pii y) {
	(x.f += y.f) %= mod1;
	if (x.f < 0) 
		x.f += mod1;
	(x.s += y.s) %= mod2;
	if (x.s < 0)
		x.s += mod2;
}

pii mult(pii x, pii y) {
	return mp(x.f * 1ll * y.f % mod1, x.s * 1ll * y.s % mod2);
}

pii hsh[N];
int pos[N];

pair<pii, int> get(int l, int r) {
	return mp(hsh[r + 1], pos[r + 1]);
}

int bp(int x, int mod) {
	int pw = mod - 2;
	int ans = 1;
	while (pw) {
		if (pw & 1) 
			ans = (ans * 1ll * x) % mod;
		x = (x * 1ll * x) % mod;
		pw /= 2;
	}
	return ans;
}

pii inv(pii x) {
	return mp(bp(x.f, mod1), bp(x.s, mod2));
}

// get(l,r)=(get(0,r)-get(0,l-1))<<pos(0, l-1)

pii shift(pii x, int val) { // to the right
	if (val > 0) {
		x = mult(x, p[val]);
	} else {
		x = mult(x, inv(p[-val]));
	}
	return x;
}

pii sum(pii x, pii y) {
	add(x, y);
	return x;
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n >> st;
	//HASH(A) = {FOR I = [0...big_N] SUM OF A[I]*T^I % MODULO} WHERE T = PRIME > 2.5 * 10^5
	p[0] = mp(1, 1);
	for (int i = 1; i < N; i++) {
		p[i] = mult(p[i - 1], mp(T, T));
	}
	pos[0] = 2 * n;
	hsh[0] = mp(0, 0);
	vector<int> a(4 * n, 0);
	for (int i = 0; i < n; i++) {
		pos[i + 1] = pos[i];
		hsh[i + 1] = hsh[i];
		if (st[i] == '+') {
			add(hsh[i + 1], p[pos[i + 1]]);
		} else if (st[i] == '-') {
			add(hsh[i + 1], mp(-p[pos[i + 1]].f, -p[pos[i + 1]].s));
		} else if (st[i] == '>') {
			pos[i + 1]++;
		} else {
			pos[i + 1]--;
		}
	}
	pii x = get(0, n - 1).f;
	ll ans = 0;
	map<pii, int> cnt;
	for (int i = 0; i < n; i++) {
		pii y = sum(shift(x, get(0, i - 1).s - 2 * n), shift(get(0, i - 1).f, 0));
		cnt[y]++;
		pii z = shift(get(0, i).f, 0);
		ans += cnt[z];
	}
	cout << ans;
	return 0;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;

  a.at(0) = toupper(a.at(0));
  b.at(0) = toupper(b.at(0));
  c.at(0) = toupper(c.at(0));

  cout << a.at(0) << b.at(0) << c.at(0) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();
        int k=sc.nextInt();

        int d[] = new int[200010];
        for(int i=0; i<n; i++) {
            d[sc.nextInt()]++;
        }
        int c=0,x=0;
        sort(d);
        for(int i=0; i<d.length; i++) {
            if(d[i]>0 ){
                if(c<1)c=i;
                x++;
            }
        }
        int ans=0;
        if(x>k){
            for(int i=1; i<=x-k; i++) {
                ans+=d[c++];
            }
        }

        out.println(ans);
        out.flush();
    }
    
    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 47828
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt

    var ans = 0
    for(i <- 1 to N) {
      var count = 0
      var num = i
      while(num > 0) {
        num = num / 10
        count += 1
      }
      if(count % 2 != 0) ans += 1
    }
    println(ans)
    }
}


Measured memory_bytes: 25416
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define bg(x) (x).begin()
#define ed(x) (x).end()
#define ar array
#define ll long long int

const int s = 2e5 + 10;
vector<int> id(s), sz(s, 1);

int find(int i) {
    while (i != id[id[i]]) {
        id[i] = id[id[i]];
        i = id[i];
    }
    return i;
}

void union_find(int x, int y) {
    int p = find(x);
    int q = find(y) ;
    // cout << p << ' ' << q << '\n';
    if (p != q) {
        id[q] = p;
        sz[p] += sz[q];
        sz[q] = 0;
    }
}


const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
      int n, m;
      cin >> n >> m;
      for (int i = 1; i <= n; ++i)
        id[i] = i;
      for (int i = 0; i < m; ++i) {
          int a, b;
          cin >> a >> b;
          union_find(a, b);
      }
      int ans = 0;
      for (int i = 1; i <= n; ++i)
        ans = max(ans, sz[i]);
      cout << ans;
    }

    return 0;
}

Measured memory_bytes: 4688
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll n,h[100005],i,j,k,l,dp[100005]={0};
    cin>>n;
    rep(i,0,n-1)cin>>h[i]; 
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    rep(i,1,n-2)
    {
        dp[i+2]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i]+abs(h[i+1]-h[i-1]));
    }cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  n = n % 10;
  string ans;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    ans = "hon";
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    ans = "pon";
  } else {
    ans = "bon";
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
n = int(input())
h = list(map(int,input().split()))

now = h[0]
count = 0
max = 0

for masu in h[1:]:
    if masu <= now:
        count += 1
        if count >= max:
            max = count
    else:
        count = 0
    now = masu

print(max)
    

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

using namespace std;

const long long INF=1e18l;
ifstream f("1.in");
ofstream g("1.out");

bool dp[Nmax]; // dp[i]-true if the first player wins, in the pile being i stones
int n, k;
int a[104];

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];


    for (int s = 0; s <= k; s++)
    {
        for (int i = 1; i <= n; i++)
        {
            int x=a[i];
             if(s >= x && !dp[s-x]) dp[s]=true;
        }

    }

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

    return 0;
}


Measured memory_bytes: 384
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
sumdigits(n, base=10) = sum(digits(n, base=10))

function main()
    a,b,c,d=parseMap(split(readline()))
    if a+b>c+d
        ans="Left"
    elseif a+b<c+d
        ans="Right"
    else
        ans="Balanced"
    end
    println(ans)
end
main()

Measured memory_bytes: 170704
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        for (int i = 0; i < n; i++) {
            int out = 0;
            boolean[] rui = new boolean[3];
            int score = 0;

            while (out != 3) {
                String event = br.readLine();
                if (event.equals("HIT")) {
                    if (rui[2])
                        score++;
                    for (int ii = 2; ii > 0; ii--) {
                        rui[ii] = rui[ii - 1];
                    }
                    rui[0] = true;
                } else if (event.equals("HOMERUN")) {
                    score += 1;
                    for (boolean b : rui) {
                        if (b)
                            score++;
                    }
                    rui = new boolean[3];
                } else if (event.equals("OUT")) {
                    out++;
                }
            }

            System.out.println(score);
        }
    }
}


Measured memory_bytes: 23944
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d[] = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        int count = 1;
        Arrays.sort(d);
        for (int i = 1; i < n; i++) {
            if (d[i] != d[i - 1]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

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

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	lint ans=0;
	rep(i,n){
		ans+=a[i]/2;
		a[i]%=2;
		if(i<n-1){
			int c=min(a[i],a[i+1]);
			ans+=c;
			a[ i ]-=c;
			a[i+1]-=c;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll ans=0, n;
    cin >> n;
    vector<ll> v(n+1,0);
    for(ll i = 1; i <= n; i++) cin >> v[i];
    ll i = 1;
    map<ll,ll> m;
    while(1)
    {

        if(i==2) break;
        if(m[i])
        {

            cout << -1;
            return 0;
        }
        m[i]++;
        i = v[i];
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 7296
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int N, M;
	vector<int>list(100005, 0);
	vector<bool>flag(100005, false);

	cin >> N >> M;

	int cnt1 = 0, cnt2 = 0;

	for (int i = 0; i < M; i++) {
		int num;
		string s;
		cin >> num >> s;
		num--;
		if (s == "WA") {
			//if (list[num] == 0) {
			if (flag[num] == false) {
				list[num]++;
				cnt1++;
			}
		}
		else if (s == "AC") {
			if (flag[num] == false) {
				flag[num] = true;
				cnt2++;
			}
		}
	}

	int cnt3 = 0, cnt4 = 0;

	for (int i = 0; i < flag.size(); i++) {
		if (flag[i] == true) {
			cnt3 += list[i];
		}
	}
	cout << cnt2 << " " << cnt3 << endl;

	return 0;
}

Measured memory_bytes: 640
package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()

	fmt.Println(min(N%K, abs(K-N%K)))
}

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

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
Node treeMinimum(Node x){
  if(x->left == NIL) return x;
  else treeMinimum(x->left);
}

Node treeMaximum(Node x){
  if(x->right == NIL) return x;
  else treeMaximum(x->right);
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  else if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

void treeDelete(Node z){
  Node y;
  Node x;
  Node a;
  if(z->left == NIL || z->right == NIL) y = z;

  else {
    while(1){
    if(z->right != NIL){
      y=treeMinimum(z->right);
      break;
    }

    a = z->parent;
    while(a != NIL && z->key == a->right->key){
      z = a;
      a = a->parent;
    }
    y=a;
    break;
  }
}

  if(y->left!=NIL) x = y->left;
  else x = y->right;

  if(x!=NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;

  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}void preorder(Node u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
N=int(input())
h=[int(i) for i in input().split()]
h=[0]+h
dp=[10**9]*(N+1)
dp[1]=0
dp[2]=dp[1]+abs(h[2]-h[1])
for i in range(2,N+1):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])
#print(dp)



Measured memory_bytes: 52208
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];

        for(int i = 0; i<n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        if(n==1) {
            System.out.println(1);
            return;

        }

        int max = 1;
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<n; j++) {
                long p = x[i]-x[j];
                long q = y[i]-y[j];
                int cnt = 0;
                if(p==0 && q==0)continue;
                for(int k = 0; k<n; k++) {
                    for (int l = 0; l < n; l++) {
                        long dx1 = x[k]-x[l];
                        long dy1 = y[k]-y[l];
                        if(p==dx1 && q==dy1) cnt++;
                    }
                }
//                System.out.println(cnt);
                max = Math.max(cnt,max);
            }
        }
//        System.out.println("max"+max);
        System.out.println(n-max);
    }

}


Measured memory_bytes: 22100
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in b:
    for j in range(0,3):
        for k in range(0,3):
            if i == a[j][k]:
                a[j][k] = 0


if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
    print("Yes")
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
    print("Yes")
elif a[2][0]==0 and a[2][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
    print("Yes")
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
    print("Yes")
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


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

ll n,m;
ll x[100100];
ll y[100100];
ll xx=0;
ll yy=0;
int main(){
	ll t,s;
	cin>>n>>m;
	cin>>t;
	for(int i=0;i<n-1;i++){
		cin>>s;
		x[i]=s-t;
		t=s;
		x[i]%=MOD;
	}
	cin>>t;
	for(int i=0;i<m-1;i++){
		cin>>s;
		y[i]=s-t;
		t=s;
		y[i]%=MOD;
	}
	for(int i=0;i<n-1;i++){
		xx+=(i+1)*(n-i-1)*x[i];
		xx%=MOD;
	}
	for(int i=0;i<m-1;i++){
		yy+=(i+1)*(m-i-1)*y[i];
		yy%=MOD;
	}
	cout<<xx*yy%MOD<<endl;
	return 0;
}

Measured memory_bytes: 1792