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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll dp[105][105];

int main(){
    int N,M;
    cin>>N>>M;
    rep(i,105){
        rep(j,105) if(i!=j) dp[i][j]=INF;
    }
    vector<vector<bool>> edge(N,vector<bool>(N));
    rep(i,M){
        ll a,b,c;
        cin>>a>>b>>c;
        dp[a-1][b-1] = c;
        dp[b-1][a-1] = c;
        edge[a-1][b-1] = true;
        edge[b-1][a-1] = true;
    }
    vector<vector<bool>> done(N,vector<bool>(N));
    rep(k,N){
        rep(i,N){
            rep(j,N) {
                if(chmin(dp[i][j],dp[i][k]+dp[k][j])) done[i][j] = true;
            }
        }
    }
    ll ans = 0;
    rep(i,N){
        rep(j,N){
            if(edge[i][j]&&done[i][j]) ans++;
        }
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 3736
A = int(input())
B = int(input())
C = int(input())
X = int(input())

a = 0
b = 0
c = 0
n=0

for a in range(A+1) :
    for b in range(B+1) :
        for c in range(C+1) :
            if 500*a + 100*b + 50*c == X :
                n+=1
        c=0
    b=0

if 0 == X :
    n+=1

print(n)
                

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if (A + B >= 10) cout << "error" << endl;
    else cout << A + B << endl;
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let sv: Vec<String> = read_col(n);
    let mat: Vec<Vec<char>> = sv.iter().map(|s| s.chars().collect()).collect();

    let mut ans = 0;

    'a: for k in 0..n {
        for i in 0..n {
            for j in i + 1..n {
                let i1 = (k + i) % n;
                let j1 = j;
                let i2 = (k + j) % n;
                let j2 = i;
                if mat[i1][j1] != mat[i2][j2] {
                    continue 'a;
                }
            }
        }
        ans += n;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

int main() {
  long long N;
  string S;
  cin >> N >> S;
  N *= 2;
  if(S[0] == 'W' || S[N-1] == 'W'){
    cout << 0 << endl;
    return 0;
  }
  vector<long long> A(N);
  A[0] = 1;
  char past = 'B';
  for(int i = 1; i < N; i++){
    if(past == 'B'){
      if(S[i] == 'B'){
        if(A[i-1] == 1) A[i] = -1;
        else if(A[i-1] == -1) A[i] = 1;
        past = 'B';
      }
      else if(S[i] == 'W'){
        if(A[i-1] == -1) A[i] = -1;
        else if(A[i-1] == 1) A[i] = 1;
        past = 'W';
      }
    }
    else if(past == 'W'){
      if(S[i] == 'W'){
        if(A[i-1] == 1) A[i] = -1;
        else if(A[i-1] == -1) A[i] = 1;
        past = 'W';
      }
      else if(S[i] == 'B'){
        if(A[i-1] == -1) A[i] = -1;
        else if(A[i-1] == 1) A[i] = 1;
        past = 'B';
      }
    }
  }

  long long res = 1;
  long long large = 1000000007;
  long long cnt = 0;
  for(int i = 0; i < N; i++){
    if(A[i] == -1){
      res *= i - cnt * 2;
      res %= large;
      cnt++;
    }
  }
  if(cnt != N/2){
    cout << 0 << endl;
    return 0;
  }
  N /= 2;
  for(; N >= 1; N--){
    res *= N;
    res %= large;
  }
  
  cout << res << endl;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,s;
int main()
{
	cin>>a>>b>>c>>n;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			if(n-(i*500+j*100)>=0&&n-(i*500+j*100)<=c*50) s++;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    ll n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if (p != 2 && p != 5)
    {
        map<int, ll> mp;
        ll cur = 0;
        ll tmp = 1;
        mp[cur]++;
        for (int i = n - 1; i >= 0; i--)
        {
            cur += (tmp * (ll)(s[i] - '0'));
            cur %= p;
            mp[cur]++;
            tmp *= 10;
            tmp %= p;
            assert(tmp != 0);
        }
        ll ans = 0;
        rep(i, p)
        {
            if (mp[i] == 0)
                continue;
            ans += (ll)mp[i] * (mp[i] - 1) / 2;
        }
        cout << ans << endl;
    }
    else if (p == 2)
    {
        ll ans = 0;
        rep(i, n)
        {
            if ((s[i] - '0') % 2 == 0)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    }
    else if (p == 5)
    {
        ll ans = 0;
        rep(i, n)
        {
            if ((s[i] - '0') % 5 == 0)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1028
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3624
import {isNumber} from "util";

function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  
  const m = parseInt(params1[1]);
  const p = lines.slice(1, m + 1).map(x => x.split(' ')[0]).map(x => parseInt(x));
  const s = lines.slice(1, m + 1).map(x => x.split(' ')[1]);

  let subject: { [n: number]: number } = {};
  let accepted = new Set();
  let accept = 0;
  let penalty = 0;
  for (let i = 0; i < m; i++) {
    if (typeof subject[p[i]] !== 'number') subject[p[i]] = 0;
    if (!accepted.has(p[i]) && s[i] === 'AC') {
      accept++;
      penalty += subject[p[i]];
      accepted.add(p[i]);
    }
    subject[p[i]]++;
  }
  console.log(`${accept} ${penalty}`);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 57764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  bool check = false;
  rep(i,n) {
    int a;
    cin >> a;
    if (a & 1) check = true;
  } 
  if (check) cout << "first" << endl;
  else cout << "second" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> ls(n), rs(n);
  ls[0]=0;
  for (int i=1; i<n; ++i) {
    ls[i] = ls[i-1] + (s[i-1]=='W' ? 1 : 0);
  }
  rs[n-1] = 0;
  for (int i=n-2; i>=0; --i) {
    rs[i] = rs[i+1] + (s[i+1]=='E' ? 1 : 0);
  }
  int ans=0xfffffff;
  for (int i=0; i<n; ++i) {
    ans = min(ans, ls[i]+rs[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String str[]=s.split(" ");
		int a=Integer.parseInt(str[0]);
		int b=Integer.parseInt(str[1]);
		int c=Integer.parseInt(str[2]);
		int k=Integer.parseInt(str[3]);
		if(a>=k)
			System.out.println(k);
		else if((a+b)>=k)
			System.out.println(a);
		else
		{
			int temp=k-(a+b);
			System.out.println(a-temp);
		}
	}
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+5;
int N;
map<string, int> m;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        string str = "";
        for(int j=0; j<10; j++)
        {
            char x;
            cin >> x;
            str+=x;
        }
        sort(str.begin(), str.end());
        ans += m[str];
        //cout << ans << "\n";
        m[str]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
    
for i in range(n-m+1):
    if b[0] in a[i]:
        p=[]
        for j in range(n-m+1):
            if b[0]==a[i][j:j+m]:
                p.append(j)
        for j in range(1,m):
            for k in p:
                if b[j]!=a[i+j][k:k+m]:
                    p.remove(k)
        if p!=[]:
            print("Yes")
            import sys
            sys.exit()
print("No")




Measured memory_bytes: 38256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 500005;

int N, D, d[MAX_N], pos[MAX_N], f[MAX_N];

int main() {
  scanf("%d%d", &N, &D);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &d[i]);
  
  pos[0] = D;
  for (int i = 1; i <= N; ++i) {
    int nxt;
    pos[i] = pos[i - 1], nxt = abs(pos[i] - d[i]);
    if (pos[i] > nxt) pos[i] = nxt;
  }

  f[N + 1] = 1;
  for (int i = N; i; --i) {
    if (f[i + 1] * 2 > d[i]) f[i] = f[i + 1] + d[i];
    else f[i] = f[i + 1];
  }

  int Q;
  scanf("%d", &Q);
  
  while (Q--) {
    int p;
    scanf("%d", &p);
    if (pos[p - 1] >= f[p + 1]) puts("YES");
    else puts("NO");
  }
  
  return 0;
}


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

int main()
{
    int t;
    cin>>t;
    while(t--){
    int a[3];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    ll ot=(a[0]*a[0])+(a[1]*a[1]);
    if(ot==(a[2]*a[2])) cout<<"YES\n";
    else cout<<"NO\n";
    }
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool f[n][10];
  for (int i = 0; i < n; i++) for (int j = 0; j < 10; j++) cin >> f[i][j];
  int p[n][11];
  for (int i = 0; i < n; i++) for (int j = 0; j < 11; j++) cin >> p[i][j];
  int x = (int) -1e9;
  for (int b = 1; b < 1 << 10; b++) {
    int m[10];
    for (int j = 0; j < 10; j++) m[j] = (b >> j) % 2;
    int t = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) c += f[i][j] == m[j] && m[j];
      t += p[i][c];
    }
    x = max(x,t);
  }
  cout << x << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;


int main() {

	int a, b;

	while (cin >> a >> b) {
		printf("%d\n", a + b);



	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3212
#!/usr/bin/python3

(n, m) = map(int, input().split())

if m % 2 == 1:
    #first half
    c = m // 2
    for i in range(c):
        print(i + 1, c * 2 + 1 - i)
        
    #second half
    f = (m // 2) * 2 + 2
    c = m // 2 + 1
    for i in range(c):
        print(f + i, f + c * 2 - 1 - i)
              
else:
    #first half
    c = m // 2
    for i in range(c):
        print(i + 1, c * 2 + 1 - i)
    #second half
    f = (m // 2) * 2 + 2
    c = m // 2
    for i in range(c):
        print(f + i, f + c * 2 - 1 - i)


Measured memory_bytes: 70288
#include <iostream>
using namespace std;
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  long long  num=0;
  if(A+B+1<C){num+=A+B+1;}
  else{num+=C;}
  num+=B;
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

long long N;
string S;
int P = 2019;

long long solve() {
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> S;
    N = S.size();
    cout << solve() << endl;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int d[300000];
int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> d[i];
	int p = d[0] / 10, flg = 1;
	if(p > 0){
		for(int i = 1; i < n - 1; i++){
			p--;
			p = max(p, d[i] / 10);
			if(p <= 0){
				flg = 0;
				break;
			}
		}
	}
	else flg = 0;
	if(flg == 1){
		p = d[n - 1] / 10;
		if(p > 0){
			for(int i = n - 2; i >= 1; i--){
				p--;
				p = max(p, d[i] / 10);
				if(p <= 0){
					flg = 0;
					break;
				}
			}
		}
		else flg = 0;
	}
	if(flg == 1) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 4280
#include <stdio.h>

#define PLAYERS_MAX_LEN 100000
#define QUIZ_MAX_LEN 100000

// player num
int n;
// initial point
int k;
// quiz num
int q;
int answers[QUIZ_MAX_LEN];
int acc[PLAYERS_MAX_LEN];

int main(void) {
    scanf("%d %d %d", &n, &k, &q);

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

    for (int i = 0; i < q; i++) {
        acc[answers[i]-1]++;
    }

    for (int i = 0; i < n; i++) {
        if ((k - (q - acc[i])) > 0) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


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

using namespace std;

int main() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<vector<int>> D(110, vector<int>());
    for (int i = 0; i < n; i++) {
      int d, v;
      cin >> d >> v;
      D[d].emplace_back(v);
    }
    for (int i = 1; i <= m; i++) {
      sort(D[i].rbegin(), D[i].rend());
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
      ans += D[i][0];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3028
S = input()
c = ['A', 'T', 'C', 'G']
ans = 0
cnt = 0
for i in range(len(S)):
	if S[i] in c:
		cnt += 1
		if i == len(S)-1:
			ans = max(cnt, ans)
	else:
		ans = max(cnt, ans)
		cnt = 0
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<climits>
#include<queue>
#include<map>
#include<functional>
using namespace std;
int main()
{
	int N,M,L,K,A,H,V=INT_MAX/2,i,j,k;
	while(scanf("%d%d%d%d%d%d",&N,&M,&L,&K,&A,&H),N)
	{
		int d[100][100],h[100]={0},t[100];
		for(i=0;i<N;t[i]=V,++i)for(j=0;j<N;++j)d[i][j]=V;
		while(L--)scanf("%d",&i),h[i]=1;
		h[A]=h[H]=1;
		while(K--)scanf("%d%d%d",&i,&j,&k),d[i][j]=d[j][i]=k;
		for(k=0;k<N;++k)for(i=0;i<N;++i)for(j=0;j<N;++j)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		typedef pair<int,int>P;	//distance, fromIndex;
		P p;
		priority_queue<P,vector<P>,greater<P> >q;
		q.push(P(0,A));
		while(q.size())
		{
			p=q.top();q.pop();
			if(t[p.second]<=p.first)continue;
			t[p.second]=p.first;
			for(i=0;i<N;++i)
				if(h[i]&& (k=d[p.second][i])!=V && k<=M)
					q.push(P(p.first+k,i));
		}
		if(t[H]==V)puts("Help!");
		else
		{
			if(t[H]<=M)printf("%d\n",t[H]);
			else printf("%d\n",2*t[H]-M);
		}
	}
	return 0;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const ll dx[] = {1,0,-1,0};
const ll dy[] = {0,1,0,-1};
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;
    vector<bool> ok(n+1,false);
    vector<ll> dp(n+1,0);
    rep(i,m){
        ll a;
        cin >> a;
        ok[a] = true;
    }
    dp[0] = 1;
    REP(i,1,n+1){
        if(ok[i]) continue;
        if(i==1) dp[i] = dp[i-1];
        else dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main() {
 int n = 0, k = 0;
 int temp = 0, sum = 0;
 int arr[1000] = { 0 };

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

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

 for (int i = 0; i <= n - 2; i++) {
  for (int j = 0; j < n - 1; j++) {

   if (arr[j] > arr[j + 1]) {
    temp = arr[j];
    arr[j] = arr[j + 1];
    arr[j + 1] = temp;
   }
  }
 }
 for (int i = 0; i < k; i++) {
  sum += arr[i];
 }
 printf("%d\n", sum);


 //system("pause");
 return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <utility>
#include <algorithm>
#include <cstdio>

#define N_MAX 1000	// ??????????????° ?????§???
#define W_MAX 1000  // ?¢¨?????????????????????????????? ?????§???

using namespace std;

int dp[N_MAX+1][W_MAX+1];
int v[N_MAX+1], w[N_MAX+1];
int N, W;

pair<int, int> knapsack() {
	int ans_w, ans_v;

	// ?????????
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = 0;
		}
	}

	// ????????¨???
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			if (w[i] <= j) {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	// ???????§£?????¢???
	ans_v = -1;
	ans_w = 0;
	for (int i = W; i >= 1; i--) {
		if (ans_v <= dp[N][i]) {
			ans_v = dp[N][i];
			ans_w = i;
		}
	}

	return make_pair(ans_v, ans_w);
}

int main() {
	int cont = 1;
	char c;
	pair<int, int> ans;

	while (cin >> W) {
		if (W == 0)  break;

		cin >> N;

		for (int i = 1; i <= N; i++) {
			cin >> v[i] >> c >> w[i];
		}

		ans = knapsack();

		printf("Case %d:\n%d\n%d\n", cont, ans.first, ans.second);
		
		cont++;
	}

	return 0;
}

Measured memory_bytes: 5064
H,W=map(int,input().split())
A,B=[],[]
for i in range(H):
  X=list(map(int, input().split()))
  A.append(X)
for i in range(H):
  X=list(map(int, input().split()))
  B.append(X)
C=[]
m=0
for i in range(H):
  D=[]
  for j in range(W):
    D.append(abs(A[i][j]-B[i][j]))
    m+=abs(A[i][j]-B[i][j])
  C.append(D)
dp=[[set() for i in range(W)] for i in range(H)]
dp[0][0].add(C[0][0])
dp[0][0].add(-C[0][0])
for i in range(H):
  for j in range(W):
    if i!=0:
      for k in dp[i-1][j]:
        dp[i][j].add(abs(k-C[i][j]))
        dp[i][j].add(abs(k+C[i][j]))
    if j!=0:
      for k in dp[i][j-1]:
        dp[i][j].add(abs(k-C[i][j]))
        dp[i][j].add(abs(k+C[i][j]))
print(min(dp[-1][-1]))

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


int main()
{
    int a,b,c,d,e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d&&c>=e){
        cout<<c<<endl;
    }
    else if(d>c&&d>=e){
        cout<<d<<endl;
    }
    else{
        cout<<e<<endl;
    }
    
    
}


Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        String w=sc.next();
        int ans=0;
        while (true){
            String s=sc.next();
            if(s.equals("END_OF_TEXT"))break;
            s=s.toLowerCase();
            s=s.replaceAll("\\,","");
            s=s.replaceAll("\\.","");
            if(s.equals(w))ans++;
        }
        out.println(ans);
    }
}


Measured memory_bytes: 26356
def cmpNum(a, b, c):
    if a < b < c:
        print('Yes')
    else:
        print('No')

def main():
    v = input()
    arr = v.split()
    cmpNum(int(arr[0]), int(arr[1]), int(arr[2]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
import java.util.*;

public class Main
{
  static int n, k;
  static int[] a;
  static Boolean[][] memo;
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
   	n = in.nextInt();
    k = in.nextInt();
    a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = in.nextInt();
    memo = new Boolean[2][k+1];
    System.out.println(dp(0, k) ? "First" : "Second");
    in.close();
  }
  
  public static boolean dp(int who, int left)
  {
	if (left < a[0])
      return false;
    if (memo[who][left] != null)
      return memo[who][left];
    boolean lose = true;
    for (int i = 0; i < n && lose; i++)
      if (a[i] <= left)
        lose &= dp(1-who, left-a[i]);
    return memo[who][left] = !lose;
  }
}

Measured memory_bytes: 34132
#include <iostream>
#include <set>
#include <vector>
#include <cassert>
using namespace std;
#define repeat(i,n) for (int i = 0; i < (n); ++i)

typedef unsigned long long hash_t;
static const hash_t base = 1e9+7; // mod is 2^64 (overflow)

int main() {
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    string s; cin >> s;
    set<hash_t> ans;
    vector<hash_t> pow(s.length()+1); pow[0] = 1;
    vector<hash_t> hash(s.length()+1); hash[0] = 0;
    repeat (i,(int)s.length()) {
        pow[i+1] = pow[i] * base;
        hash[i+1] = hash[i] * base + s[i];
    }
    int l = 0, r = 1; // [l,r)
    repeat (k,m) {
        string query; cin >> query;
        if      (query == "L++") ++ l;
        else if (query == "L--") -- l;
        else if (query == "R++") ++ r;
        else if (query == "R--") -- r;
        else assert(false);
        hash_t h = hash[r] - hash[l] * pow[r-l];
        ans.insert(h);
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 20160
def examC():
    N, A, B, C = LI()
    L = [I() for _ in range(N)]
    loop = 4**N; ans = 10**9
    for i in range(loop):
        cur = 0
        curA = 0; curB = 0; curC = 0
        for j in range(N):
            judge = (i//(4**j))%4
            if judge==1:
                if curA>0:
                    cur +=10
                curA += L[j]
            elif judge==2:
                if curB>0:
                    cur +=10
                curB += L[j]
            elif judge==3:
                if curC>0:
                    cur +=10
                curC += L[j]
        if curA==0 or curB==0 or curC==0:
            continue
        cur += abs(curA-A)
        cur += abs(curB-B)
        cur += abs(curC-C)
        ans = min(cur,ans)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 50416
#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
int main() {
  unordered_map<string, int> m;
  int n;
  string s;
  std::cin >> n;
  while(n > 0) {
    std::cin >> s;
    if (m.count(s)) {
      m[s] += 1;
    } else {
      m.insert(pair<string, int>(s, 1));
    }
    n--;
  }
  cout << m.size() << "\n";
  return 0;
}

Measured memory_bytes: 17800
#include <iostream>
using namespace std;
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    int c=0;
    scanf("%d%d",&a,&b);

    for(int i=a; i<=b; i++)
    {
        int m=0,x=i;
        while(x)
        {
        m=m*10+x%10;
        x/=10;
        }
        if(m==i)
            c++;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

lli n;
lli a[100005][4];
lli dp[100005][4];
lli fun(lli day, lli flag)
{
	if (day == n)
		return 0;
	if (dp[day][flag] != -1)
		return dp[day][flag];
	lli mx = 0;
	if (flag == 0)
	{
		mx = max(mx, a[day][1] + fun(day + 1, 1));
		mx = max(mx, a[day][2] + fun(day + 1, 2));
		mx = max(mx, a[day][3] + fun(day + 1, 3));
	}
	else if (flag == 1)
	{
		mx = max(mx, a[day][2] + fun(day + 1, 2));
		mx = max(mx, a[day][3] + fun(day + 1, 3));
	}
	else if (flag == 2)
	{
		mx = max(mx, a[day][1] + fun(day + 1, 1));
		mx = max(mx, a[day][3] + fun(day + 1, 3));
	}
	else
	{
		mx = max(mx, a[day][1] + fun(day + 1, 1));
		mx = max(mx, a[day][2] + fun(day + 1, 2));
	}
	return dp[day][flag] = mx;
}
void solve()
{
	cin >> n;
	f(i, 0, n - 1)
	f(j, 1, 3)
	cin >> a[i][j];
	memset(dp, -1, sizeof(dp));
	cout << fun(0, 0);
}
int main()
{
	IOS;
	solve();
	return 0;
}

Measured memory_bytes: 17664
#include<stdio.h>
#define N 36

struct A{
  int num;
  char cha;
};

int main(){
  int i, j, s, minj, tempi, flag = 0;
  char tempc;
  struct A a[N], b[N];

  scanf("%d",&s);
  for(i = 0; i < s; i++){
    scanf(" %c%d",&a[i].cha,&a[i].num);
    b[i].cha = a[i].cha;
    b[i].num = a[i].num;
  }

  for(i = 0; i < s; i++){
    for(j = s - 1; j > i; j--){
      if(a[j].num < a[j-1].num){
	tempi = a[j].num;
	tempc = a[j].cha;
	a[j].num = a[j-1].num;
	a[j].cha = a[j-1].cha;
	a[j-1].num = tempi;
	a[j-1].cha = tempc;
      }
    }
  }
  for(i = 0; i < s; i++){
    printf("%c%d",a[i].cha,a[i].num);
    if(i != s - 1) printf(" ");
  }
  printf("\nStable\n");
  
  for(i = 0; i < s; i++){
    minj = i;
    for(j = i; j < s; j++){
      if(b[j].num < b[minj].num) minj = j;
    }
    tempi = b[i].num;
    tempc = b[i].cha;
    b[i].num = b[minj].num;
    b[i].cha = b[minj].cha;
    b[minj].num = tempi;
    b[minj].cha = tempc;
  }
  for(i = 0; i < s; i++){
    printf("%c%d",b[i].cha,b[i].num);
    if(i != s - 1) printf(" ");
  }
  printf("\n");
  for(i = 0; i < s; i++){
    if(b[i].cha != a[i].cha) flag = 1;
    else if(b[i].num != a[i].num) flag = 1;
  }
  if(flag == 0) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

Measured memory_bytes: 612
monster_hp,typeCnt_deathblow = gets.split(" ").map(&:to_i)
point_deathblow = gets.split(" ").map(&:to_i)

point_deathblow.each do |n|
  monster_hp = monster_hp - n
end

if monster_hp <= 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 20220
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	
	if(k<=a)
	{
		cout<<k<<endl;
	}
	else if(k<=a+b)
	{
		cout<<a<<endl;
	}
	else if(k<=a+b+c)
	{
		cout<<a-(k-a-b)<<endl;
	}

	
}

Measured memory_bytes: 3636
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def get_pattern(A, B, pos, pre):
    if pre == 0:
        if A[pos] == B[pos]:
            return 3, pos+1, 1
        elif A[pos] == A[pos+1]:
            return 6, pos+2, 2
    if pre == 1:
        if A[pos] == B[pos]:
            return 2, pos+1, 1
        elif A[pos] == A[pos+1]:
            return 2, pos+2, 2
    if pre == 2:
        if A[pos] == B[pos]:
            return 1, pos+1, 1
        elif A[pos] == A[pos+1]:
            return 3, pos+2, 2

def run():
    N = int(input())
    S1 = input()
    S2 = input()
    pos = 0
    pre = 0
    ans = 1
    while pos < N:
        val, pos, pre = get_pattern(S1, S2, pos, pre)
        #print(val)
        ans *= val
        ans %= mod

    print(ans)

if __name__ == "__main__":
    run()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin>>n>>k;
  vi S(101,0);
  rep(i,k){
    int d;
    cin>>d;
    vi A(101);
    rep(j,d){
      cin>>A[i];
      A[i]--;
      S[A[i]]++;
    }
  }
  int cnt = 0;
  rep(i,n)if(S[i] > 0)cnt++;
  cout<<n-cnt<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(0); std::cin.tie(0);
ll a[112345];
int main() {
	ll n, t, q, b, c, sum = 0;
	cin >> n;
	ll i;
	for (i = 0; i < n; ++i) {
		cin >> t;
		++a[t];
		sum += t;
	}
	cin >> q;
	for (i = 0; i < q; ++i) {
		cin >> b >> c;
		t = a[b];
		a[b] = 0;
		sum -= b * t;
		a[c] += t;
		sum += c * t;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vl vector <long>
#define vll vector < ll >
#define pll pair < ll , ll >
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MODCONST 1000000007
//#define v[i] abs(v[i])

using namespace std;

void solve()
{
    ll n,k;
    cin>>n;
    vll dp(3,0);
    rep(i,0,n){
        vll c;
        rep(j,0,3){
            cin>>k;
            c.pb(k);
        }
        if(i==0){
            dp[0]=c[0];
            dp[1]=c[1];
            dp[2]=c[2];
        }else{
            vll dp2 = dp;
            rep(j,0,3){
                dp[j] = c[j] + max(dp2[(j+1)%3],dp2[(j+2)%3]);
            }
        }
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;
}

int main()
{
    fastio ;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll tc=1;
    //cin>>tc; //for number of testcases
    //ll ts = tc;
    while(tc--){
        //cout<<"Case #"<<ts-tc<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    char s[11];
    char output[11];
    cin>>s;
    int x=0;
    int len = strlen(s);
    for(int i=0;i<len;i++)
    {
        if(s[i]=='0')
        {
            output[x]='0';
            x++;
        }

        else if( s[i]=='1')
        {
            output[x]='1';
            x++;
        }

        else{
            if(x!=0)
            x--;
        }
    }

    for(int i=0;i<x;i++)
    cout<<output[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c)cout<<1<<endl;
    
    else if(a!=b&&b!=c&&c!=a)cout<<3<<endl;
  else cout<<2<<endl;
    
    
}

Measured memory_bytes: 256
N = int(input())
words = {}
for i in range(N):
    name = input()
    if name not in words:
        words[name] = 1
    elif name in words:
        words[name] += 1

max_num = max(words.values())
max_name_list = [word[0] for word in words.items() if word[1] == max_num]

max_name_list = sorted(max_name_list)

for i in range(len(max_name_list)):
    print(max_name_list[i])


Measured memory_bytes: 32988
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] nums = new int[4];
        for (int i = 0; i < 4; i++) {
            nums[i] = Integer.parseInt(s.substring(i, i + 1));
        }
        int tmp;
        for (int i = 0; i < 8; i++) {
            tmp = nums[0];
            for (int j = 0; j < 3; j++) {
                tmp += nums[j + 1] * (i % Math.pow(2, j + 1) - i % Math.pow(2, j) != 0 ? 1 : -1);
            }
            if (tmp==7) {
                for (int j = 0; j < 3; j++) {
                    System.out.print(nums[j]);
                    System.out.print(i % Math.pow(2, j + 1) - i % Math.pow(2, j) != 0 ? "+" : "-");
                }
                System.out.println(nums[3]+"=7");
                return;
            }
        }
    }
}


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

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define true 1
#define false 0


int main(void){
	char* x;
	int counter = 0;
	int ans = 0;
	x = calloc(sizeof(char),200000);
	scanf("%s",x);
	while(*x){
		if(*x == 'T'){
			if(counter == 0){
				ans++;
			}
			counter = max(0,counter-1);
		}else{
			counter++;
		}
		x++;
	}
	printf("%d\n", ans+counter);
	return 0;
}

Measured memory_bytes: 384
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
A=V[::2]
B=V[1::2]
A_counter=Counter(A)
a_freqnum=A_counter.most_common()[0][0]
a_freq=A_counter.most_common()[0][1]
B_counter=Counter(B)
b_freqnum=B_counter.most_common()[0][0]
b_freq=B_counter.most_common()[0][1]
if a_freqnum!=b_freqnum:
    ans=n-(a_freq+b_freq)
else:
    if a_freq==n//2:
        if b_freq==n//2:
            ans=n//2
        else:
            b_freq_sec=B_counter.most_common()[1][1]
            ans=n//2-b_freq_sec
    else:
        a_freq_sec=A_counter.most_common()[1][1]
        if b_freq==n//2:
            ans=n//2-a_freq_sec
        else:
            b_freq_sec=B_counter.most_common()[1][1]
            ans=n-a_freq-max(a_freq_sec,b_freq_sec)
print(ans)

Measured memory_bytes: 19552
def B():
    a,v = list(map(int, input().split()))
    b,w = list(map(int, input().split()))
    t = int(input())
    if a < b and v*t+a < w*t+b:
        print("NO")
    elif b < a and v*t*(-1)+a > w*t*(-1)+b:
        print("NO")
    else:
        print("YES")
B()

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

#define ARRSIZE 2001
int n, Arr[21];
int find(int i, int m){
	if( m == 0) return 1;
	if( i > n ) return 0;
	int res = find(i + 1, m) || find(i + 1, m - Arr[i]);
	return res;
}

int main(){
	int q;
	int m;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> Arr[i];
	} 

	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> m;
		if( find(0, m)){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	return 0;
}


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

int main(){
    long long A,B,C;
    cin >> A >> B >> C;
    if(A%2==0||B%2==0||C%2==0){
        cout << 0 << endl;
    }else{
        long long ans1,ans2,ans3;
        ans1=abs((A/2)*B*C-(A-A/2)*B*C);
        ans2=abs((B/2)*A*C-(B-B/2)*A*C);
        ans3=abs((C/2)*B*A-(C-C/2)*B*A);
        cout << min(ans1,min(ans2,ans3)) << endl;
    }
}


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(x);
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3660
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

main {
  int x, y;
  cin >> x >> y;
  int t[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (t[x] == t[y] ? "Yes" : "No") << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<string> v;

// 下、右、上、左
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main()
{
    int H, W;
    cin >> H >> W;

    v.resize(H);

    REP(i, H)
    {
        cin >> v[i];
    }

    bool flg = true;
    REP(i, H)
    {
        REP(j, W)
        {
            if (v[i][j] == '#')
            {
                int valid = 0;
                int time = 0;
                for (int k = 0; k < 4; k++)
                {
                    int nx = j + dx[k];
                    int ny = i + dy[k];

                    if (nx < 0 || W <= nx
                        || ny < 0 || H <= ny) continue;

                    valid++;

                    if (v[ny][nx] == '#') continue;

                    if (v[ny][nx] == '.') time++;
                }

                if (valid == time)
                {
                    flg = false;
                    break;
                }
            }
        }
        if (!flg) break;
    }

    cout << (flg ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int h, w, a, b;

int main() {
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for (int i=0;i<b;i++) {
        for (int j=0;j<a;j++) printf("0");
        for (int j=a;j<w;j++) printf("1");
        printf("\n");
    }
    for (int i=0;i<h-b;i++) {
        for (int j=0;j<a;j++) printf("1");
        for (int j=a;j<w;j++) printf("0");
        printf("\n");
    }

	return 0;
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;


    string s;

    cin >> k;

    cin >> s;

    if(s.length() > k)
    {
        rep0(i,k)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    else
    {
        cout << s << endl;
    }
    
    

    //cout << 0 << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    int a;
    int b;
    scanf("%d %d",&a,&b);
    if(0<a&&a<10&&0<b&&b<10){
        int c;
        c=a*b;
        printf("%d",c);
    }
    else {
        int d=-1;
        printf("%d",d);
    }
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict

N, P = map(int, input().split())
S = input().strip()[::-1]

if P in [2, 5]:
    ans = 0
    for r in range(N):
        if int(S[r]) % P == 0:
            ans += N - r
    print(ans)
    exit()

cum = [0] * (N + 1)
for i in range(N):
    now = int(S[i]) * pow(10, i, P)
    cum[i + 1] = (cum[i] + now) % P

cnt = defaultdict(int)
for _cum in cum:
    cnt[_cum] += 1

ans = 0
for k, v in cnt.items():
    ans += v * (v - 1) // 2

print(ans)


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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int w[n],e[n];
    rep(i,n){
        w[i] = 0; e[i] = 0;
    }
    rep(i,n-1){
        if(s[i] == 'W'){
            w[i+1] = w[i]+1;
        }else{
            w[i+1] = w[i];
        }
    }
    for(int i = n-1; i > 0; i--){
        if(s[i] == 'E'){
            e[i-1] = e[i]+1;
        }else{
            e[i-1] = e[i];
        }
    }
    int ans = inf;
    rep(i,n){
        ans = min(ans,w[i]+e[i]);
    }
    cout << ans << endl;
}

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

c = [0]*4
for i in range(n):
    s = input()
    if s == 'AC':
        c[0] += 1
    if s == 'WA':
        c[1] += 1
    if s == 'TLE':
        c[2] += 1
    if s == 'RE':
        c[3] += 1
    
print('AC x', c[0])
print('WA x', c[1])
print('TLE x', c[2])
print('RE x', c[3])


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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1000005
#define MAXC 205
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll x, y;
	cin >> x >> y;
	if((x%y) == 0) { cout << -1 << endl; }
	else cout << x << endl;
}

Measured memory_bytes: 764
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    D, T, S = LI()
    if D / S <= T:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}


Measured memory_bytes: 3608