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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int ac = 0, wa = 0;
  vector<int> p(n + 1, 0);
  vector<int> pen(n + 1, 0);
  for(int i = 0; i < m; ++i) {
    int x; string s;
    cin >> x >> s;
    if(s == "WA") {
      if(p[x] != -1) {
        pen[x]++;
      }
    } else {
      if(p[x] != -1) {
        ac++;
        wa += pen[x];
      }
      p[x] = -1;
    }
  }
  cout << ac << ' ' << wa << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

string grid[50];

int x_move[4] = {-1, 1, 0, 0};
int y_move[4] = {0, 0, -1, 1};
bool is_isolated(int i, int j, int H, int W){
  for(int k = 0; k < 4; k++){
    int test_x = i + x_move[k];
    int test_y = j + y_move[k];
    if(0 <= test_x && test_x < H && 0 <= test_y && test_y < W
      && grid[test_x][test_y] == '#'){
        return false;
      }
  }
  return true;
}

int main(){
  int H;
  int W;
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    cin >> grid[i];
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      //cout << i << " " << j << " " << is_isolated(i, j, H, W) << endl;
      if(grid[i][j] == '#' && is_isolated(i, j, H, W)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

#define ll long long

int main() {
    ll sum=0,ans=-1;
    ll n;
    cin>>n;
    n--;
    sum=(n*(n+1))/2;
    std::cout << sum << std::endl;
	return 0;
}

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

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N,K;
	cin >>N >>K;
	vector<int> A(N);
	rep(i,N) scanf("%d", &A[i]);
	int remain = N - 1;
	int ans = 0;
	while (remain>0) {
		remain -= K-1;
		ans++;
	}
	cout << ans;
	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,tot,p1[6005],p2[6005],num[6005];
char s[6005],ans[6005];
void solve(int l,int r)
{
	if(l>r)return;
	int now1=0,now2=0;
	for(int i=l;i<=r;i++)
	{
		if(s[i]=='a')p1[++now1]=i;
		else p2[++now2]=i;
	}
	int maxx=-1;
	for(int i=1;i<=now1;i++)
	{
		num[i]=0;
		if(p1[i]>p2[i])
		{
			for(int j=p2[i]+1;j<p1[i];j++)
			  if(s[j]=='b')num[i]++;
			maxx=max(maxx,num[i]);
		}
		else num[i]=-1;
	}
	if(maxx==-1)
	{
		int nowr=l-1;
		for(int i=1;i<=now1;i++)
		{
			if(p1[i]<nowr)continue;
			ans[++tot]='a';
			ans[++tot]='b';
			nowr=p2[i];
		}
		return;
	}
	int pos=0;
	for(int i=1;i<=now1;i++)
	{
		if(num[i]<0)continue;
		if(!pos)pos=i;
		else
		{
			int p=pos,j=i;
			while(num[p]&&num[j]&&num[p]==num[j])p++,j++;
			if(num[p]<num[j])pos=i;
		}
	}
	int c=0,i=p2[pos];
	for(;;i++)
	{
		if(i>p2[pos]&&i<p1[pos]&&s[i]=='a')continue;
		ans[++tot]=s[i];
		if(s[i]=='b')c++;
		else c--;
		if(c==0)break;
	}
	solve(i+1,r);
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	solve(1,2*n);
	for(int i=1;i<=tot;i++)putchar(ans[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  if(N % 10 == 9)
    cout << "Yes" << endl;
  else if(N / 10 == 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a, b, c = [], [], []
for i in range(n):
    av, bv = map(int, input().split())
    a.append(av)
    b.append(bv)
    c.append((i, av + bv))

c = sorted(c, key=lambda x: x[1], reverse=True)
takahaship, aokip = 0, 0
i = 0
for _ in c:
    if i % 2 == 0:
        takahaship += a[c[i][0]]
    else:
        aokip += b[c[i][0]]
    i += 1
print(takahaship - aokip)


Measured memory_bytes: 26876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string t;
  for(int i =0;i<s.size();i++){
    if(s.at(i) == 'B' ){
      if( t != ""){
      t.erase(t.end()-1);
      }
    }
    else{
      t.push_back(s.at(i));
    }
  }
  cout << t;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int k , a , b ;
  cin >> k >> a >>  b ;
  bool ans = false ;
  
  rep(i,10000){
    int x = k ;
    x *= i ;
    if(x>= a && x<= b) ans = true;
  }
  
  if(ans) cout << "OK";
  else    cout << "NG" ;


}


Measured memory_bytes: 3600
array= []
for i in range(3):
    array.append(list(map(int,input().split())))
n= int(input())
number=[]
answer = "No"
for i in range(n):
    number.append(input())

for i in range (3):
    for j in range(3):
        for k in range(n):
            if int(array[i][j]) == int(number[k]):
                array[i][j] = 8101919

for i in range (3):
    if array[i][0] & array[i][1] & array[i][2] == 8101919:        
        answer = "Yes"

for i in range(3):
    if array[0][i] & array[1][i] & array[2][i] == 8101919:
        answer = "Yes"

if array[0][0] & array[1][1] & array[2][2] == 8101919:
    answer = "Yes"
           
if array[2][0] & array[1][1] & array [0][2] == 8101919:
    answer = "Yes"

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pow3(x) ((x)*(x)*(x))
#define mul(x,y) (((x)%P*(y))%P)
#define pls(x,y) ((x)%P+(y))%P
using namespace std;
const long long P=1e9+7;
const int N=100020;
long long qpow(long long x,long long k)
{
    long long rt=1,base=x;
    while(k)
    {
        if(k&1)rt=mul(rt,base);
        base=mul(base,base),k>>=1;
    }return rt;
}
int fac[N*2];
long long solve(int h,int w)
{
    long long rt=0;
    rt=fac[h+w-2];
    rt=mul(rt,mul(qpow(fac[h+w-2-h+1],P-2),qpow(fac[h-1],P-2)));
    return rt;
}
int main()
{
    int H,W,A,B;
    long long ans=0;
    scanf("%d%d%d%d",&H,&W,&A,&B);
    fac[0]=1;for(int i=1;i<=H+W-2;i++)fac[i]=mul(fac[i-1],i);
    for(int i=B+1;i<=W;i++)
        ans=pls(ans,mul(solve(H-A,i),solve(A,W-i+1)));
    cout<<ans;
    return 0;
}
/*5
2 5
1 2 1
1 2 0
2 3 2
2 3 0
2 3 4

Process returned 0 (0x0)   execution time : 1.220 s
Press any key to continue.

*/


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

typedef struct {
	int bunsi,bunbo;
	int oto;
} note_t;

void yakubun(note_t *note) {
	int a=note->bunsi,b=note->bunbo,r;
	if(a>0) {
		while(b>0) {
			r=a%b;
			a=b;
			b=r;
		}
		note->bunsi/=a;
		note->bunbo/=a;
	} else {
		note->bunsi=0;
		note->bunbo=1;
	}
}

int main(void) {
	int case_num,case_count;
	if(scanf("%d",&case_num)!=1)return 1;
	for(case_count=0;case_count<case_num;case_count++) {
		static note_t notes[1024*8];
		int notes_count=0;
		char input[4096];
		int N,i,j;
		int anslen;
		static int answer[1024];
		if(scanf("%d",&N)!=1)return 1;
		for(i=0;i<N;i++) {
			int len;
			if(scanf("%s",input)!=1)return 1;
			len=strlen(input)/2;
			for(j=0;input[j*2];j++) {
				char buf[4];
				int oto;
				buf[0]=input[j*2];
				buf[1]=input[j*2+1];
				buf[2]='\0';
				if(sscanf(buf,"%x",&oto)!=1)return 1;
				if(oto!=0) {
					notes[notes_count].bunsi=j;
					notes[notes_count].bunbo=len;
					notes[notes_count].oto=oto;
					yakubun(&notes[notes_count]);
					notes_count++;
				}
			}
		}
		anslen=1;
		for(i=0;i<notes_count;i++) {
			int a=anslen,b=notes[i].bunbo,r;
			while(b>0) {
				r=a%b;
				a=b;
				b=r;
			}
			anslen=anslen/a*notes[i].bunbo;
			if(anslen>1024) {
				anslen=-1;
				break;
			}
		}
		if(anslen>0) {
			for(i=0;i<anslen;i++)answer[i]=0;
			for(i=0;i<notes_count;i++) {
				int s=notes[i].bunsi;
				int b=notes[i].bunbo;
				int o=notes[i].oto;
				answer[s*(anslen/b)]|=o;
			}
			for(i=0;i<anslen;i++)printf("%02X",answer[i]);
			putchar('\n');
		} else {
			puts("Too complex.");
		}
	}
	return 0;
}

Measured memory_bytes: 748
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////


#define N 62
int main(){fastio
    
    ll n,k;cin>>n>>k;
    ll dp[n][N];
    rep(i,0,n-1){
        cin>>dp[i][0];dp[i][0]--;
    }
    rep(j,1,N-1){
        rep(i,0,n-1){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
    ll ans=0;
    rep(j,0,N-1){
        if((k>>j)&1){
            ans=dp[ans][j];
        }
    }
    cout<<ans+1<<endl;
    
    
    return 0;
}



Measured memory_bytes: 100520
import sys

v = None
for i in sys.stdin:
    if v:
        h = 0
        for j, n in enumerate(i.split()):
            if n == v[j]:
                h += 10
            elif n in v:
                h += 1
        v = None
        print(h // 10, h % 10)
    else:
        v = i.split()

Measured memory_bytes: 7156
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
  ll int l,r;
  cin>>l;
  double f=(l)/(double)3.0;
  
  double ans=pow(f,3.0);
  printf("%.8lf",ans);
}



	
  
  

		
		
		
		
		
		
	
	
	 
		
		
	
	
	

	


	
	
	
   



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, m)cin >> b[i];
	bool exist = false;
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (i + m - 1 >= n || j + m - 1 >= n)continue;
			bool match = true;
			rep(k, 0, m) {
				rep(l, 0, m) {
					if (a[i + k][j + l] != b[k][l]) {
						match = false;
						break;
					}
				}
			}
			if (match)exist = true;
		}
	}
	if (exist)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x,a=map(int,input().split())
    if(x<a):
        print(0)
    else:
        print(10)
resolve()

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

using namespace std;

const int N = 2020;
long long dp[N][N];

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; i++) {
                cin >> a[i].first;
                a[i].second = -i;
        }
        sort(a.begin(), a.end());
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                        int id = -a[i].second;
                        dp[i + 1][j] = dp[i][j] + 1ll * (i - id + j) * a[i].first;
                        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j + 1] + 1ll * (id - j) * a[i].first);
                }
        }
        cout << dp[n][0] << '\n';
        return 0;
}

Measured memory_bytes: 35220
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cmath>
#include<set>
#include<stack>

using namespace std;

int main()
{
    float a[7]={35.50,37.50,40,43,50,55,70};
    float b[7]={71,77,83,89,105,116,148};
    string c[7]={"AAA","AA","A","B","C","D","E"};
    float x,y;
    while(cin>>x>>y) {
        for(int i=0;i<7;i++){
            if(a[i]<=x)continue;
            for(int j=0;j<7;j++){
                if(b[j]>y){
                    cout<<c[max(i,j)]<<endl;
                    goto ne;
                }
            }
        }
        cout<<"NA"<<endl;
    ne:;
    }
//    freopen("/Users/shitian/Desktop/gcj/gcj/B-large-practice.in", "r", stdin);
//    freopen("/Users/shitian/Desktop/gcj/gcj/out.txt", "w", stdout);
//    int tcase;
//    cin>>tcase;
//    for(int tca=1;tca<=tcase;tca++){
//        cout<<"Case #"<<tca<<": ";
//
//    }
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi a(n);
    REP(i,n) cin>>a[i];

    vl cs(n+1);
    unordered_map<ll,ll> cnt;
    ll ans = 0;
    cnt[0] = 1;
    ll zero = 0;
    REP(i,n){
        cs[i+1] = cs[i]+a[i];
        cnt[cs[i+1]]++;
    }

    for(auto& e : cnt){
        //DEBUG2(e.first, e.second);
        ans += (e.second * (e.second-1)) / 2LL;
    }

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

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

namespace CSharpSample01
{

	class Program
	{
		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			Console.Write($"{inputNum[2]} {inputNum[0]} {inputNum[1]}");

		}

	}
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll w, h, n;
  ll xmax[100005];
  cin >> w >> h >> n;
  fill(xmax, xmax + h + 1, 0);
  ll x, y;
  rep(i, n) {
    cin >> x >> y;
    xmax[y] = max(xmax[y], x);
  }
  ll result = INF;
  for (int i = h - 2; i >= 0; i--) {
    xmax[i] = max(xmax[i], xmax[i + 1]);
  }
  for (int i = 0; i < h; i++) {
    result = min(result, i + xmax[i + 1]);
  }
  cout << result << endl;
	return 0;
}


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

int main(){
   int n; cin>>n;
   string s; cin>>s;
   int cnt=1;
   for(int i=1;i<n;i++){
      if(s[i]!=s[i-1]) cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}

   


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
   int N,n,i,j,k,v;
   int A[100];
   scanf("%d",&N);
	
   for(i=0;i<N;i++){
      scanf("%d",&n);
      A[i] = n;
   }
	//printf("do");
	
	for(k=0;k<N-1;k++){
			printf("%d ",A[k]);
		}
	printf("%d\n",A[k]);
	
	for(i=1;i<N;i++){
		v = A[i];
		j = i-1;
		while(j>=0&&A[j]>v){
			A[j+1] = A[j];
			j--;
			A[j+1] = v;
		}
		for(k=0;k<N-1;k++){
			printf("%d ",A[k]);
		}
		printf("%d\n",A[k]);;
	}	
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
 
int main(){
    int n; cin >> n;
    int d; cin >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n;i++){
        for(int j = i+1;j < n;j++){
            int norm = 0;
            for(int k = 0;k < d;k++){
                int diff = abs(x[i][k] - x[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for(int k = 0;k <= norm;k++){
                if(k * k == norm){
                    flag = true;
                }
            }   
            if(flag) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
H, W, K =  [int(i) for i in input().split()]

masme = []
for i in range(H):
    masme.append(list(input()))

#print(masme)

h_p = []
for h in range(pow(2,H)):
    h_p.append(str(bin(h))[2:].zfill(H))

#print(h_p)

w_p = []
for w in range(pow(2,W)):
    w_p.append(str(bin(w))[2:].zfill(W))

#print(w_p)

def count(mas):
    ans = 0
    for i in mas:
        for j in i:
            if( j == "#"):
                ans += 1
    return ans

def delete_row(mas, i):
    ilist = list(i)
    #print(ilist)
    ans = []
    for n in range(H):
        #print(ilist[n])
        if ilist[n] == "0":
            ans.append(mas[n])
            #print(ans)
    return ans

def delete_column(mas, i):
    ilist = list(i)
    ans = []
    for row in mas:
        #print(row)
        tmp_row=[]
        for n in range(W):
            if(ilist[n] == "0"):
                tmp_row.append(row[n])
        #print(tmp_row)
        ans.append(tmp_row)
    return ans


ans_cnt = 0
for h in h_p:
    for w in w_p:
        tmp = delete_row(masme, h)
        tmp2= delete_column(tmp, w)
        cnt = count(tmp2)
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Measured memory_bytes: 9204
n,k=gets.split.map(&:to_f)
a=gets.split.map(&:to_i)
pl=a.index(1)
list=[]
k.to_i.times{|i|
  list<<[((pl+i-k+1)/(k-1)).ceil,0].max+[((n-(i+1)-pl)/(k-1)).ceil,0].max
  }
#list=[[((pl-2)/(k-1)).ceil,0].max+[((n-1-pl)/(k-1)).ceil,0].max,[((pl-1)/(k-1)).ceil,0].max+[((n-2-pl)/(k-1)).ceil,0].max,[(pl/(k-1)).ceil,0].max+[((n-3-pl)/(k-1)).ceil,0].max]
p list.min+1

Measured memory_bytes: 11652
import sys
input = sys.stdin.readline
n,m,x = map(int,input().split())
c = []
a = []
ans = 10**9
check = False
for _ in range(n):
  dc,*da = map(int,input().split())
  c.append(dc)
  a.append(da)
for i in range(1,1<<n):
  study = [0]*m
  total = 0
  for j in range(n):
    if (i>>j)%2:
      total += c[j]
      for k in range(m):
        study[k] += a[j][k]
  if all([l>=x for l in study]):
    check = True
    ans = min(ans,total)
if check:
  print(ans)
else:
  print(-1)

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

int main(){
    long long n,k,l,i=0;
    scanf("%lld %lld",&n,&k);
    if(n%k==0) l=0;
    else{
      n=(n%k);
      while(1){
          n=abs(n-k);
          if(n>l){
          if(i!=0) break;
            i=1;
          }
          l=n;
      }
    }
    printf("%lld",l);

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
#define int long long
using namespace std;

typedef long long ll;

string s;

bool check(int l1,int r1,int l2,int r2){
    string a,b;
    for(int i(0);i<r1-l1+1;i++){
        a+=s[l1+i];
        b+=s[l2+i];
    }
    return (a!=b);
}

int dp[300000][7];

main()
{
    ios_base::sync_with_stdio(0);
    cin >> s;
    dp[0][1] = 1;
    for(int i(1);i < s.size();i++){
        for(int sz1(1);sz1 < 7;sz1++){
            if(i-sz1+1<0)break;
            for(int sz2(1);sz2 < 7;sz2++){
                if(i-sz1-sz2+1<0)continue;
                if(sz1!=sz2){
                    dp[i][sz1] = max(dp[i][sz1],dp[i-sz1][sz2]+1);
                    continue;
                }
                int l1 = i-sz1+1;
                int r1 = i;
                int l2 = i-2*sz1+1;
                int r2 = i-sz1;
                if(!check(l1,r1,l2,r2))continue;
                dp[i][sz1] = max(dp[i][sz1],dp[i-sz1][sz2]+1);
            }
        }
    }
    int ans = 0;
    for(int i(1);i<=6;i++){
        ans = max(ans,dp[s.size()-1][i]);
    }
    cout << ans;
    return 0;
}
/*
*/



Measured memory_bytes: 12820
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int search(int*d, int t, int n) {
	if (d[n - 1] < t)return n - 1;
	int r = 0;
	for (int i = 15; i >= 0; i--) {
		int c = r | (1 << i);
		if (c >= n)continue;
		if (d[c] < t)r = c;
	}
	return r;
}

int main() {
	int N;
	scanf("%d", &N);
	int*L = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", L + i);
	std::sort(L, L + N);
	long long res = 0;
	for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) {
		int M = L[i] + L[j];
		int c = search(L, M, N);
		res += c - j;
	}
	printf("%lld", res);
	return 0;
}

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

int water[31] = {}, sugar[3001] = {};

int main(){
    int a, b, c, d, e, f, i, j, mx_water, mx_sugar = 0;
    cin >> a >> b >> c >> d >> e >> f;
    water[0] = 1;
    for(i=0; i*a<=f/100; i++){
        water[i*a] = 1;
    }
    for(i=0; i<=f/100; i++){
        if(water[i] == 1 && (i+b)*100 <= f){
            water[i+b] = 1;
        }
    }
    for(i=0; i*c<=f; i++){
        sugar[i*c] = 1;
    }
    for(i=0; i<=f; i++){
        if(sugar[i] == 1 && (i+d) <= f){
            sugar[i+d] = 1;
        }
    }
    mx_water = a*100;
    for(i=1; i<=f/100; i++){
        if(water[i] == 1){
            for(j=min(f-i*100, i*e); j>=0; j--){
                if(sugar[j] == 1){
                    if((mx_sugar*(i*100 + j) < j*(mx_sugar + mx_water))){
                        mx_sugar = j;
                        mx_water = i*100;
                    }
                    j = -1;
                }
            }
        }
    }
    cout << mx_water+mx_sugar << " " << mx_sugar;
    return 0;
}

Measured memory_bytes: 256
commands = {"W": (-1, 0), "E": (1, 0), "S": (0, -1), "N": (0, 1)}

while True:
    n = int(input())
    if n == 0:
        break
    gems = []
    ans = "No"
    for i in range(n):
        gems.append(list(map(int, input().split())))
    m = int(input())
    pos = [10, 10]
    for i in range(m):
        direction, step = input().split()
        for j in range(int(step)):
            pos[0] += commands[direction][0]
            pos[1] += commands[direction][1]
            if pos in gems:
                gems.remove(pos)
    if not gems:
        ans = "Yes"
    print(ans)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  ll a[10];
  REP(i, n)
  {
    a[i] = stoll(s.substr(i, 1));
  }

  int mask = (1 << n - 1);

  ll ans = 0;
  REP(i, mask)
  {
    ll c = 0;
    REP(j, n - 1)
    {
      c = c * 10 + a[j];
      int bit = ((i >> (n - 2 - j)) & 1);
      if (bit == 1)
      {
        ans += c;
        c = 0;
      }
    }
    c = c * 10 + a[n - 1];
    ans += c;
  }

  cout << ans << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double l;
    cin>>l;
    long double x=l/3;
    cout << fixed << setprecision(10) << x*x*x <<"\n";
	return 0;
}

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

using namespace std;
int main(){
    int a,b;
    int ans=1;
    
    cin >> a >> b;
    int count = a;
    if (b == 1){
        cout << 0;
    }else{
      while(count < b ) {
          count += a-1;
          ans++;
      }
      cout << ans;
    }
}

Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_f).map { |e| (e+1.0)/2.0 }
sum = a[0..k-1].inject(:+)
ans = sum
(k..n-1).each do |i|
  sum = sum - a[i-k] + a[i]
  ans = [ans, sum].max
end
puts sprintf("%.12f", ans)

Measured memory_bytes: 21124
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    ll k, a, b;
    cin >> k >> a >> b;

    if(a >= k){
        cout << 1 << endl;
        return 0;
    }

    ll s = a - b;
    if(s <= 0){
        cout << -1 << endl;
        return 0;
    }

    ll rate;
    ll count;
    count = (k - a) / s * 2 + 1;
    rate = a + s * ((count-1) / 2);
    if(rate == k){
        cout << count << endl;
        return 0;
    }

    cout << count + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace DPL_1_B_0_1_Knapsack_Problem
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int[] input = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int count = input[0];
			int weight = input[1];

			Item[] item = new Item[count + 1];
			item[0] = new Item (0, 0);

			for (int lp = 1; lp < count + 1; lp++)
			{
				input = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				item[lp] = new Item (input[0], input[1]);
			}

			//process
			int[,] selectArray = new int[count + 1, weight + 1];

			for (int lp = 1; lp < count + 1; lp++)
			{
				for (int w = 1; w < weight + 1; w++)
				{
					//アイテムを選択することができるのであれば
					if (item[lp].Weight <= w)
					{
						if (selectArray[lp - 1, w] < item[lp].Value + selectArray[lp - 1, w - item[lp].Weight])
						{
							//選ぶ
							selectArray[lp, w] = selectArray[lp - 1, w - item[lp].Weight] + item[lp].Value;
						}
						else
						{
							//選ばない
							selectArray[lp, w] = selectArray[lp - 1, w];
						}
					}
					else
					{
						//選べない
						selectArray[lp, w] = selectArray[lp - 1, w];
					}
				}
			}

			Console.WriteLine (selectArray[count,weight]);
		}
	}

	class Item
	{
		public Item ( int value, int weight )
		{
			this.Value = value;
			this.Weight = weight;
		}

		public int Value { private set; get; }
		public int Weight { private set; get; }
	}
}



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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  vector<char> results;

  while (true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    char result;
    int mf = m + f;

    if (m == -1 || f == -1) {
      result = 'F';
    } else if (mf >= 80) {
      result = 'A';
    } else if (mf >= 65) {
      result = 'B';
    } else if (mf >= 50) {
      result = 'C';
    } else if (mf >= 30) {
      result = 'D';
      if (r >= 50) {
        result = 'C';
      }
    } else {
      result = 'F';
    }

    results.push_back(result);
  }

  for (auto &&i : results) {
    printf("%c\n", i);
  }
}



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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k; cin >> n >> k;
    string s;
    cin >> s;
    int cnt=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            cnt++;
        }
    }
    int ans;
    ans=min(cnt+2*k,n-1);
    cout << ans << endl;
}


Measured memory_bytes: 512
a,b,c,x,y = list(map(int,input().split()))
ans = 0
if a + b >= c*2:
    ans += c * (min(x,y)) * 2
    if x >= y:
        if a > 2*c:
            cost = 2* c
        else:  
            cost = a
        ans += cost* (x-y)
    else:
        if b > 2*c:
            cost = 2*c
        else:
            cost = b
        ans += cost * (y-x)
    
else:
  ans = x*a + y*b
  
print(ans)

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

class Dice{
public:
    int face[6], facetmp[6];

    Dice(void){
        for (int i = 0; i < 6; i++){
            face[i] = 0;
            facetmp[i] = 0;
        }
    }

    void move(char ch){
        for (int i = 0; i < 6; i++) {
            facetmp[i] = face[i];
        }

        if (ch == 'E') {
            facetmp[0] = face[3];
            facetmp[2] = face[0];
            facetmp[3] = face[5];
            facetmp[5] = face[2];
        }

        else if (ch == 'W') {
            facetmp[0] = face[2];
            facetmp[2] = face[5];
            facetmp[3] = face[0];
            facetmp[5] = face[3];
        }

        else if (ch == 'N') {
            facetmp[0] = face[1];
            facetmp[1] = face[5];
            facetmp[4] = face[0];
            facetmp[5] = face[4];
        }

        else if (ch == 'S') {
            facetmp[0] = face[4];
            facetmp[1] = face[0];
            facetmp[4] = face[5];
            facetmp[5] = face[1];
        }

        else if (ch == 'Z'){
            facetmp[1] = face[3];
            facetmp[2] = face[1];
            facetmp[3] = face[4];
            facetmp[4] = face[2];
        }

        for (int i = 0; i < 6; i++){
            face[i] = facetmp[i];
        }

    }

    void print(){
        cout << face[0] << endl;
    }

};

int main() {
    Dice d1, d2;
    int num1[6], num2, flag = 0;
    string order = "";
    for (int i = 0; i < 6; i++){
        cin >> num1[i];
        d1.face[i] = num1[i];
    }
    for (int i = 0; i < 6; i++){
        cin >> num2;
        d2.face[i] = num2;
    }

    for (int j = 0; j <= 3; j++){
        for (int k = 0; k <= 3; k++){
            for (int n = 0; n <= 3; n++){
                order.clear();
                order.append(j,'E');
                order.append(k,'S');
                order.append(n,'Z');

                for (int i = 0; i < 6; i++){
                    d1.face[i] = num1[i];
                }

                for (int m = 0; m < order.size(); m++){
                    d1.move(order[m]);
                }
                if (d1.face[0] == d2.face[0] &&
                        d1.face[1] == d2.face[1] &&
                        d1.face[2] == d2.face[2] &&
                        d1.face[3] == d2.face[3] &&
                        d1.face[4] == d2.face[4] &&
                        d1.face[5] == d2.face[5]){
                    cout << "Yes" << endl;
                    j = 3;
                    k = 3;
                    n = 3;
                    flag = 1;
                }
            }

        }
    }
    if (flag == 0){
        cout << "No" << endl;
    }
    return 0;
}

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

int N;
string S;

void input(){
    cin >> N;
    cin >> S;
}

void solve(){
    int itr = N % 26;
    int Size = (int)(S.length());
    for(int i = 0; i < Size; i++){
        if (S[i] + itr <= 90){
            S[i] += itr;
        }else if(S[i] + itr > 90){
            S[i] = S[i] + itr - 26;
        }
    }
    cout << S << '\n';
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	char s[110];
	cin >> s;
	rep(i, strlen(s) - 8) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int x = NextInt, a = NextInt;
            if (x < a)
            {
                System.Console.WriteLine(0);
            }
            else
            {
                System.Console.WriteLine(10);
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

int main(){
    int N;

    scanf("%d", &N);

    long long int *A = (long long int *) malloc(sizeof(long long int) * N);

    for(int i = 0; i < N; i ++){
        scanf("%lld", A + i);
    }
    long long int sum = 0;

    for(int i = 0; i < N; i ++){
        sum += A[i];
    }
    long long int part_sum = 0;
    long long int min_diff = sum;

    for(int i = 0; i < N; i ++){
        part_sum += A[i];
        long long int diff = labs(sum - 2 * part_sum);

        if(diff < min_diff){
            min_diff = diff;
        }else if(diff > min_diff){
            break;
        }
    }
    printf("%lld\n", min_diff);
}

Measured memory_bytes: 1664
n,m=map(int,input().split())
seq=[list(map(int,input().split())) for  _ in range(m)]



count=0
while(True):
    flg=1
    for i in range(m):
#         print()
        s,c=seq[i]
        keta=len(str(count))
        if keta<n:
            flg=0
#             print("ttttt")
            break
        k=str(count)
        s-=1
        if int(k[s])!=c:
            flg=0
    if flg==1:
        break
    count+=1
    if count==1000:
        break
if flg==1:
    if (count==0)and(n!=1):
        print(10**(n-1))
    else:
        print(count)
else:
    print(-1)

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

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


int main (){
    ll a;
    cin>>a;
    if(a%2==0) cout<<a<<endl;
    else cout<<a*2<<endl;
    return 0;
}


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

#define int long long
#define endl '\n'

#ifdef LOCAL
#include <C:\Programs\prettyprint.hpp>
template <typename ...Ts>
void trace1(Ts ...T){ ((cerr << "{ " << T << " }\n" ), ...); }
#define trace(...) cerr << "[" #__VA_ARGS__ << "] : " << '\n', trace1(__VA_ARGS__), cerr << '\n';
#else
#define trace(...)
#define trace1(...)
#endif

set<int> factorize(int n) {
    set<int> a;
    for (int i = 2; i * i <= n; i++) {
        if (n % i)  continue;
        while (n % i == 0)
            n /= i;
        a.insert(i);
    }
    if (n > 1)
        a.insert(n);
    return a;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int a, b; cin >> a >> b;
    auto k1 = factorize(a), k2 = factorize(b);
    trace(k1);
    trace(k2);
    {
        vector<int> to_erase;
        for (auto i: k2)    if (!k1.count(i))
            to_erase.push_back(i);
        for (auto i: to_erase)
            k2.erase(i);
    }
    cout << (int)k2.size() + 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);
	
	
	long long n,k;
	cin>>n>>k;

	long long a[n];
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
	}
	 
	sort(a,a+n,greater<long long>());

	long long sum=0;
	for(long long i=k;i<n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;



}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c;
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);

	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 768
#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<int,int>;

int main()
{
  ll H,W;
  cin >> H >> W;
  if(H%3==0||W%3==0){
    cout << 0 << endl;
  }else{
    ll ans = min(H,W);
    FOR(i,H/3-5,H/3+5){
      FOR(j,W/2-5,W/2+5){
        if(i<0||i>H-1||j<0||j>W-1) continue;
        ll x = i*W;
        ll y = (H-i)*j;
        ll z = (H-i)*(W-j);
        ll MAX = max(x,max(y,z));
        ll MIN = min(x,min(y,z));
        ans = min(ans,MAX-MIN);
      }
    }
    FOR(i,W/3-5,W/3+5){
      FOR(j,H/2-5,H/2+5){
        if(i<0||i>W-1||j<0||j>H-1) continue;
        ll x = i*H;
        ll y = (W-i)*j;
        ll z = (W-i)*(H-j);
        ll MAX = max(x,max(y,z));
        ll MIN = min(x,min(y,z));
        ans = min(ans,MAX-MIN);
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d,e=0,f;
  cin >>a>>b;
  if(a%b==0) cout <<0<<'\n';
  else cout <<1<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;


int main() {
    string s;
    string t;
    int a,b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s == u) {
        cout << a-1 <<' '<< b;
    }else {
        cout << a << ' ' <<b-1;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(4));
	rep(i,n)rep(j,4)cin>>in[i][j];
	vi x,y;
	rep(i,n)rep(j,4)if(j%2)y.pb(in[i][j]);
					else x.pb(in[i][j]);
	sort(all(x));sort(all(y));
	x.erase(unique(all(x)),x.end());
	y.erase(unique(all(y)),y.end());
	
	vvi tmp=in;
	rep(i,n)rep(j,4)if(j%2)tmp[i][j]=find(all(y),tmp[i][j])-y.begin();
					else tmp[i][j]=find(all(x),tmp[i][j])-x.begin();
	vvi field(x.size(),vi(y.size()));
	rep(i,n)loop(j,tmp[i][0],tmp[i][2])loop(k,tmp[i][1],tmp[i][3])
		field[j][k]=true;
	ll out=0;
	rep(i,x.size())rep(j,y.size())if(field[i][j])
		out+=(ll)(x[i+1]-x[i])*(y[j+1]-y[j]);
	cout<<out<<endl;
}

Measured memory_bytes: 65644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート 1,2,....9
}

int main(void){
    ll N, x, a[105], ans=0;
    in2(N, x);
    rep(i, N) in(a[i]);
    qsort(a, N, sizeof(ll), cmp);
    for(ll i=0; i<N-1 && x>=a[i]; i++){
        ans++;
        x -= a[i];
    }
    if(x==a[N-1]) ans++;
    put(ans);
    return 0;
}


Measured memory_bytes: 128
s=["S", "H", "C", "D"]

n=int(input())

table=[[False]*14 for i in range(4)]


for loop in range(n):
    mark,num = input().split()
    num = int(num)
    if mark=="S":
        table[0][num]=True
    elif mark=="H":
        table[1][num]=True
    elif mark=="C":
        table[2][num]=True
    else:
        table[3][num]=True
        
for i in range(4):
    for j in range(1,14):
        if table[i][j]==False:
            print("%s %d" %(s[i], j))


Measured memory_bytes: 5608
program main;

var N, M, i: integer;
  A: array[1..100] of integer;
  total, count: integer;
  
begin

  readln(N, M);
  for i := 1 to N do read(A[i]);
  total := 0;
  for i := 1 to N do total := total + A[i];
  
  count := 0;
  for i := 1 to N do
    if A[i] >= total/(4*M)
      then count := count + 1;
  
  if count >= M
    then writeln('Yes')
    else writeln('No');
    
end.

Measured memory_bytes: 1380
import java.util.*;

public class Main{
	
	static int gcd(int a,int b) {
		return a%b==0?b:gcd(b,a%b);
	}
	
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),x=s.nextInt();
		
		int g=-1;
		
		for(int i=0;i<n;++i) {
			int y=s.nextInt();
			if(g==-1)
				g=Math.abs(y-x);
			else
				g=gcd(g,Math.abs(y-x));
			y=x;
		}
		System.out.println(g);
	}
}


Measured memory_bytes: 48224
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;

public class Main {
	//2-100
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int t = in.nextInt();
		if (n%x==0) {
			int total = n/x;
			System.out.println(total*t);
		}else {
			int total = n/x;
			System.out.println((total+1)*t);
		}
		
		
		
	}
	

}

Measured memory_bytes: 26996
def gcd(a,b):
    if(a == 0):
        return b
    else:
        return gcd(b % a, a)
    
def lcmm(l,m):

    prod = l * m

    gcD = gcd(l,m)

    return (prod // gcD)

n = int(input().strip())

lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)
    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll i,j,k,t,n,a,b;
    cin>>n;
    ll c=0;
    for(i=1;i<=n;i++)
    {
        cin>>k;
        if(k%2==1&&i%2==1)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    
    if(S[2] == S[3] && S[4] == S[5]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if(N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    N /= 2;
    int ans = 0;
    while(N > 0) {
        ans += N / 5;
        N /= 5;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;int a[110],b[110];
	cin>>n;
	fori(n)cin>>a[i];
	fori(n)cin>>b[i];

	ll answer=0;
	fori(n){
		ll score=0;
		for(int j=0;j<=i;++j){score+=a[j];}
		for(int j=i;j<n;++j){score+=b[j];}
		answer=max(answer,score);
	}
	cout<<answer;
}

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

int main() {

  int n, d;
  cin >> n >> d;

  int num = d * 2 + 1;
  if(n % num == 0) cout << n / num <<endl;
  else cout << n / num + 1 << endl;
}

Measured memory_bytes: 256