akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 2 * 100'000 + 5;

i64 n;
i64 a[MAXN];
map<i64, i64> c;


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;
    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (i64 i = 2; i <= n; i++) {
        c[i - a[i]] += 1;
    }

    i64 R = 0;
    for (i64 i = 1; i < n; i++) {
        R += c[a[i] + i];
        c[i + 1 - a[i + 1]] -= 1;
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 27784
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll Str2Long(string s){
    reverse(ALL(s));
    ll n = 0;
    rep(i, s.size()){
        n += (s[i]-'0')*pow(10, i);
    }
    return n;
}

ll func(string s, ll n){
    if(Str2Long(s) > n)return 0;
    ll res = 0;

    bool has3, has5, has7;
    has3 = has5 = has7 = false;

    rep(i, s.size()){
        if(s[i] == '3')has3 = true;
        else if(s[i] == '5')has5 = true;
        else has7 = true;
    }
    if(has3 && has5 && has7 && Str2Long(s) <= n)res++;
    
    res += func(s+'3', n) + func(s+'5', n) + func(s+'7', n);

    return res;
}

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

    cout << func("", n) << endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int n;
    cin>>n;
    if     (n<1200)cout<<"ABC\n";
    else if(n<2800)cout<<"ARC\n";
    else           cout<<"AGC\n";

    return 0;
}


Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-05-19 20:38:53
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int head[maxn],nex[maxn*2],ver[maxn*2];
LL edge[maxn*2];
int tot;
void add(int x,int y,LL z){
	ver[++tot] = y,edge[tot] = z,nex[tot] = head[x],head[x] = tot;
}
bool t[maxn];
void dfs(int x,int fa,int f){
	for(int i = head[x];i;i = nex[i]){
		int y = ver[i];
		if(y == fa) continue;
		int vv = f;
		if(edge[i]&1) vv ^= 1;
		t[y] = vv;
		dfs(y,x,vv);
	}
}
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	int x,y,z;
	for(int i = 0;i < n-1;i++){
		cin >> x >> y >> z;
		add(x,y,z);
		add(y,x,z);
	}
	t[1] = 0;
	dfs(1,0,0);
	for(int i = 1;i <= n;i++)
		cout << t[i] << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, n;
    int ans = 1;
    string s;
    cin >> n >> s;
    rep(i,n-1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//Problem D
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,a[N],b[N][N],d[N],m;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int s,b;
        scanf("%d%d",&s,&b);
        a[i<<1]=s+b,a[i<<1|1]=s-b;
    }
    for(int i=1;i<n<<1;i++)if((a[i]^a[0])&1){printf("-1");return 0;}
    //for(int i=0;i<n<<1;i++)printf("%d ",a[i]);printf("\n");
    for(int k=30;~k;k--){
        int v=1<<k;d[++m]=v;
        for(int i=0;i<n<<1;i++){
            if(0<=a[i])b[i][m]=1,a[i]-=v;
            else a[i]+=v;
        }//for(int i=0;i<n<<1;i++)printf("%d ",a[i]);printf("\n");
    }
    if(a[0]){
        d[++m]=1;
        for(int i=0;i<n<<1;i++)if(a[i]==1)b[i][m]=1;
    }
    printf("%d\n",m);
    for(int i=1;i<=m;i++)printf("%d ",d[i]);printf("\n");
    for(int i=0;i<n;i++){
        for(int j=1;j<=m;j++){
            if(b[i<<1][j]==0&&b[i<<1|1][j]==0)printf("L");
            if(b[i<<1][j]==1&&b[i<<1|1][j]==1)printf("R");
            if(b[i<<1][j]==0&&b[i<<1|1][j]==1)printf("D");
            if(b[i<<1][j]==1&&b[i<<1|1][j]==0)printf("U");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int n, x[10], y[10];

int facto(int a){
  if(a == 1) return 1;
  return a * facto(a - 1);
}

int main(){
  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];
  int seq[10];
  rep(i, n) seq[i] = i;
  double res = 0;
  do{
    rep(i, n - 1){
      double num = sqrt(pow(x[seq[i + 1]] - x[seq[i]], 2) + pow(y[seq[i + 1]] - y[seq[i]], 2));
      res += num;
    }
  }while(next_permutation(seq, seq + n));
  res /= facto(n);
  cout << setprecision(10) << res << endl;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, b, t;
  cin >> a >> b >> t;

  cout << (t / a) * b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int k,s;cin>>k>>s;
	int ans=0;
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k&&i+j<=s;j++){
			if(s-i-j>=0&&s-i-j<=k) ans++;
		}
		cout<<ans;
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int N,M,P,X[1000];
	int i;
	int sum,ans,winner;
	while(1){
		sum = 0;
		cin >> N >> M >> P;
		if(N == 0 && M == 0 && P == 0){
			break;
		}
		for(i = 1 ; i <= N ; i++){
		cin >> X[i];
			sum += X[i];
			if(M == i){
				winner = X[i];
			}
		}
			if(winner == 0){
				cout << 0 << endl;
		}
			else{
				ans=(100*sum-(100*sum*P/100))/winner;
					cout << ans << endl;
				}
				}
				return 0;
			}

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

int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  int i = a.size() - 1;
  int j = b.size() - 1;
  if(a[i] == b[0] && b[j] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#!python3.4.3
import math

n = int(input())
x = n / 1.08
x = math.floor(x)

if math.floor(x*1.08) == n:
    print(x)
elif math.floor((x+1)*1.08) == n:
    print(x+1)
else:
    print(':(')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MAX = LLONG_MAX;

int main()
{

  ll n, k;
  cin >> n >> k;

  ll a[n];

  for (int i = 0; i < n; i++)
    cin >> a[i];

  ll sum = 0;
  ll ng = 0, ok = 100000000000;
  ll mid, ans, tmp;

  while (ok - ng > 1)
  {
    sum = 0;
    mid = (ok + ng) / 2;
    //cout << ok << " " << ng << " " << mid << endl;

    for (int i = 0; i < n; i++)
    {
      tmp = (a[i] + (mid - 1)) / mid - 1;
      if (tmp < 0)
        tmp = 0;
      sum += tmp;
    }

    //cout << sum << endl;

    if (sum <= k)
      ok = mid;
    else
      ng = mid;
  }

  ans = ok;

  cout << ans << endl;
}


Measured memory_bytes: 5184
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		Set<String> items = new HashSet<>();

		for(int i=0;i<N;i++) {
			items.add(sc.next());
		}
		System.out.println(items.size());
	}
}


Measured memory_bytes: 66796
#include<stdio.h>
int main(){
int x[3000];
int y[3000];
int i=0;
int count=0;

while(1){
scanf("%d %d",&x[i],&y[i]);
if(x[i] == 0 && y[i] == 0) break;
i++;
count++;
}

for(i=0;i<count;i++){
if(x[i] < y[i]) printf("%d %d\n",x[i],y[i]);
else printf("%d %d\n",y[i],x[i]);
}
return 0;
}



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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};
//ll i,j,k;

int main() {
	ll n;
	cin>>n;
	if(n <= 999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def inc(y, x):
	return 0 <= y < H and 0 <= x < W

H, W = map(int, input().split())
Sy, Sx = map(int, input().split())
Gy, Gx = map(int, input().split())
"""
a = [[] for i in range(h)]
for i in range(h):
    a[i] = input()
"""
a = [input() for i in range(H)]

DH = [1, 0, -1, 0]
DW = [0, 1, 0, -1]

#同じ大きさの行列を作って最短路をメモする発想がなかった
visit = [[1e8 for i in range(W)] for j in range(H)]
visit[Sy-1][Sx-1]=0 #sy-1, sx-1に注意
deq = deque([(Sy-1, Sx-1)])

while deq:
    h, w = deq.pop()
    for dh, dw in zip(DH, DW):
        x = w+dw; y=h+dh
        if inc(y, x)==False or a[y][x]=='#':
            continue
        if visit[y][x] > visit[h][w]:
            visit[y][x] = visit[h][w]
            deq.append((y,x))
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if inc(h+dh, w+dw)==False or a[h+dh][w+dw]=='#':
                continue
            if visit[h+dh][w+dw] > visit[h][w]+1: 
                visit[h+dh][w+dw] = visit[h][w]+1
                deq.appendleft((h+dh, w+dw))
if visit[Gy-1][Gx-1] == 1e8:
    print(-1)
else:
    print(visit[Gy-1][Gx-1])

Measured memory_bytes: 101448
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	char c=s[0];
	cin>>s;
	int t=s.size();
	for(int i=1;i<=s.size()-1;i++){
		if(s[i]==s[i-1]){
			//s=s.substr(0,i-1)+s.substr(i+1,s.size()-1);
			t--;
		}
	} 
	cout<<t<<endl;
	return 0;
} 

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

struct UF{
	vector<int> parent;
	UF(int n){
		parent.assign(n,-1);
	}
	int find(int x){
		if(parent[x]<0)return x;
		else return parent[x]=find(parent[x]); 
	}

	int size(int x){
		return -parent[find(x)];
	}

	bool unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y)return false;
		if(size(x)<size(y))swap(x,y);
		parent[x]+=parent[y];
		parent[y]=x;
		return true;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	int a[m],b[m];
	UF Uni(n);
	vector<long long> ans(m);
	ans[m-1]=(long long)n*(n-1)/2;
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
	}
	for(int i=m-1;i>=1;i--){
		if(Uni.find(a[i])!=Uni.find(b[i])){
			ans[i-1]=ans[i]-(long long)Uni.size(a[i])*Uni.size(b[i]);
			Uni.unite(a[i],b[i]);
		}else ans[i-1]=ans[i];
	}
	rep(i,m)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<long> h(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> h[i];
    }
    long prev=0;
    long counter=0;
    for(size_t i=0;i<N; i++)
    {
        if(h[i] > prev)
        {
            counter += h[i] - prev;
            prev = h[i];
        }else
        {
            prev = h[i];
        }
    }
    cout << counter << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Integer N;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		int[][] x = new int[N][];
		int[][] y = new int[N][];
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(sc.next());
			x[i] = new int[A[i]];
			y[i] = new int[A[i]];
			for(int j = 0; j < A[i]; j++) {
				x[i][j] = Integer.parseInt(sc.next()) - 1;
				y[i][j] = Integer.parseInt(sc.next());
			}
		}
		sc.close();

		int res = 0;
		for(int bit = 0; bit < (1 << N); bit++) {
			if(judge(bit, A, x, y)) {
				int count = 0;
				for(int i = 0; i < N; i++) {
					if((bit & (1 << i)) != 0) count++;
				}
				res = Math.max(res, count);
			}
		}
		System.out.println(res);

	}

	//整数bitに対応する「決め打ち」が整合しているかどうか判定
	public static boolean judge(int bit, int[] A, int[][] x, int[][] y) {
		for(int i = 0; i < N; i++) {
			if((bit & (1 << i)) == 0) {
				continue;
			}
			for(int k = 0; k < A[i]; k++) {
				int a = x[i][k];
				int b = y[i][k];

				//b = 0なのに「正直者」ならダメ
				if(b == 0 && ((bit & (1 << a)) != 0)) return false;
				//b = 1なのに「不親切」ならダメ
				if(b == 1 && ((bit & (1 << a)) == 0)) return false;
			}
		}
		return true;
	}
}

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

const int N = 1e5 + 5;

vector<int> v;
int n, s;
bool flag;

int main() {
#ifdef HOME
	freopen("agc16b.in", "r", stdin);
	freopen("agc16b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	sort(begin(v), end(v));
	if (v.back() - v.front() > 1) {
		cout << "No\n";
		return 0; }

	if (v.back() - v.front() == 0) {
		if (v.size() >= v[0] * 2 || v.size() == v[0] + 1)
			cout << "Yes\n";
		else
			cout << "No\n"; }
	else {
		flag = v.back() > n;
		for (auto i: v)
			s+= int(v.front() == i);

		if (s + (n - s) / 2 < v.back())
			flag = true;
		if (n - s < 2)
			flag = true;
		if (s >= v.back())
			flag = true;

		if (flag)
			cout << "No\n";
		else
			cout << "Yes\n"; }

	return 0; }


Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;



int main(){
    int n;
    cin>>n;
    if(n>999){cout<<"ABD"<<endl;}
    else{cout<<"ABC"<<endl;}
    
    
    
    return 0;
}




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

int main(){
    int n, ma = -1e9, idx;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        ma = max(ma, A[i]);
        if(ma == A[i]) idx = i;
    }

    int mi = 1e9, b;
    for(int i = 0; i < n; i++){
        if(idx == i) continue;
        if(mi > abs(A[i] - ma / 2)){
            b = A[i];
            mi = abs(A[i] - ma / 2);
        }
    }
    cout << ma << " " << b << endl;

    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int size = S.size();
    string dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    char c;
    for (int i = 0;i < size;i++){
        c = S[i];
        S[i] = dict[dict.find(c) + N];
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y;
    cin >> X >> Y;
    print(X + Y/2);
}


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

int sum(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int n, min = -1;
    cin >> n;
    for (int a = 1; a < n; a++)
    {
        int b = n - a;
        int sum_ = sum(a) + sum(b);
        if (min == -1 || min > sum_) min = sum_;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

if 0 < a and 0 < c:
  # 両方正
  print(b * d)
elif b <= 0 and d <= 0:
  # 両方負
  print(a * c)
else:
  # 片方が負
  # 区間に0を含む場合
  print(max(a * c, a * d, b * c, b * d))


Measured memory_bytes: 9184
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string stra,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    multiset<int> s;
    cin>>n;
    vector<ll> v(n-1);
    rep(i,n-1) cin>>v[i];
    sum+=v[0];
    sum+=v[n-2];
    for(ll i=0;i<n-2;i++){
        sum+=min(v[i],v[i+1]);
    }
    cout<<sum<<endl;



    return 0;
}


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

int main(){
    int a, b;
    int ans = 0;
    cin >> a >> b;
    for(size_t i = 0; i < 2; i++)
    {
        if(a >= b){
            ans+= a;
            a--;
        }
        else{
            ans += b;
            b--;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum ^= a[i];
  }
  rep(i, n) {
    ll ans = sum;
    ans ^= a[i];
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll k;
/******* define variable end *******/
ll solve() {
  cin >> k;
  queue<ll> q;
  for (ll i = 1; i <= 9; i++) {
    q.push(i);
  }
  ll tmp;
  REP(i, k) {
    tmp = q.front();
    q.pop();
    if (tmp % 10 != 0) {
      q.push(10 * tmp + tmp % 10 - 1);
    }
    q.push(10 * tmp + tmp % 10);
    if (tmp % 10 != 9) {
      q.push(10 * tmp + tmp % 10 + 1);
    }
  }
  cout << tmp << endl;
  return 0;
}
int main() {
  // clock_t start = clock();
  cout << std::fixed << std::setprecision(10);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll end_solve = solve();
  /*
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
  1000.0; printf("time %lf[ms]\n", time);
  */

  return (int)end_solve;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int i,sum=0,n,s[11],temp;
	scanf("%d",&n);
	temp = n;
	for(i=1;i<=10;i++){
		s[i] = temp%10;
		temp = (temp-s[i])/10;
		sum += s[i];
	}
	printf(n%sum==0?"Yes":"No");
	return 0;
}


Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C

#D
def bellman_ford(start):
    dist = [float("inf") for i in range(n)]
    dist[start] = 0
    for i in range(n-1):
        update = False
        for j, k, l in adj:
                if dist[k] > dist[j] + l:
                    dist[k] = dist[j] + l
                    update = True
        if not update:
            break
    negative = [False for i in range(n)]
    for j, k, l in adj:
        if dist[k] > dist[j] + l:
            dist[k] = dist[j] + l
            negative[k] = True
    return dist,negative[n-1]
n,m = LI()
adj = []
for i in range(m):
    a,b,c = LI()
    a -= 1
    b -= 1
    adj.append([a,b,-c])
d,ne = bellman_ford(0)
if ne:
    print("inf")
else:
    print(-d[-1])
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 42844
def main():
    N, M, Q = map(int, input().split())  # 入力

    kumi = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        kumi.append([a, b, c, d])

    A = [1]*N

    flg = True

    s = 0
    ans = None

    while flg:
        # print(A)
        t_s = rtn_score(A, kumi)
        if t_s > s:
            s = t_s
            ans = A
        for i in range(N):
            if A[N - 1 - i] < M:
                A[N - 1 - i] += 1
                break
            else:
                if A[N - 1 - i - 1] < M:
                    A[N - 1 - i - 1] += 1
                    for j in range(i+1):
                        A[N - 1 - j] = A[N - 1 - i - 1]
                    break
            if i == N - 1:  # last
                flg = False

    print(s)


def rtn_score(A, kumi):
    tmp_s = 0
    for k in kumi:
        # print(k)
        # print(k[1])
        if A[k[1]-1] - A[k[0]-1] == k[2]:
            tmp_s += k[3]
    return tmp_s


if __name__ == "__main__":
    main()


Measured memory_bytes: 9268
#include <stdio.h>

int main() {
	int n;
	int a, b, c, d;
	int count;

	while (scanf("%d", &n) != EOF) {
		count = 0;
		for (a = 0; a < 10; a++) {
			for (b = 0; b < 10; b++) {
				for (c = 0; c < 10; c++) {
					for (d = 0; d < 10; d++) {
						if (a + b + c + d == n) {
							count++;
							break;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 596
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, x; cin >> k >> x;
    if (500 * k >= x) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    ll k = (1 + sqrt(1+8*N)) / 2;
    if ( k*(k-1) < 2*N ) k++;
    if ( k*(k-1) != 2*N ) {
        cout << "No" << "\n";
        return 0;
    }
    vector<vector<int>> ans(k);
    int i = 1;
    for ( int k1 = 0; k1 < k; k1++ ) {
        for ( int k2 = 0; k2 < k1; k2++ ) {
            ans[k1].push_back(i);
            ans[k2].push_back(i);
            i++;
        }
    }

    cout << "Yes" << "\n";
    cout << ans.size() << "\n";
    for ( int i = 0; i < k; i++ ) {
        cout << ans[i].size();
        for ( int j = 0; j < ans[i].size(); j++ ) {
            cout << " " << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}

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

Measured memory_bytes: 2304
from collections import deque

if __name__ == "__main__":
    n, m = map(int, input().split())
    edge = list()
    for i in range(m):
        edge.append(list(map(int, input().split())))

    ans = 0

    for i in range(m):
        distance = [-1] * n
        que = deque([0])
        graph = dict()
        for j in range(n):
            graph[j] = []

        distance[0] = 0  # 初期条件(スタート地点)

        for j in range(m):
            if i != j:
                graph[edge[j][0]-1].append(edge[j][1]-1)
                graph[edge[j][1]-1].append(edge[j][0]-1)

        # 幅優先探索
        while len(que) != 0:
            v = que.popleft()
            for g in graph[v]:
                if distance[g] != -1:
                    continue
                distance[g] = distance[v] + 1
                que.append(g)

        for d in distance:
            if d == -1:
                ans += 1
                break

    print(str(ans))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    for(int i=0;i<b.length();i++)
    {
        cout<<a[i]<<b[i];
    }
    if(a.length()>b.length())
    {
        cout<<a[a.length()-1]<<endl;
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    string s,t;
    ld a,b,h,m;
    cin >> a >> b >> h >> m;

    ld time = h * 60 + m;
    long double a_th = time * Pi / 30, b_th = time * Pi / 360;

    ld p = abs(a * sin(a_th) - b * sin(b_th)), q = abs(a * cos(a_th) - b * cos(b_th));

    ld ans = sqrt(p*p + q*q);

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

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

int main(){
   double x,t;
   cin >> x >> t;
   printf("%09f\n",x/t);
   return 0;
}  


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

using namespace std;

int main(void) {
    long n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    long old = 0;
    for(int i=0; i<n; i++) {
        if(s[i] == 'R' && i+1 < n && s[i+1] == 'R') old++;
        if(s[i] == 'L' && i-1 >=0 && s[i-1] == 'L') old++;
    }

    long r = 0;
    {
        int i=0, j=n-1;
        while(k > 0 && i < j) {
            while(i < j && !(s[i] != s[i+1])) i++;
            while(i < j && !(s[j] != s[j-1])) j--;
            if(i < j)
                r += 1 + (i < j-1), k--;
            i++, j--;
        }
    }

    cout << r + old << endl;


}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] people = new int[n];
        for (int i = 0; i < n; i++) {
            people[i] = sc.nextInt();
        }
        int ok = 0;
        for (int h : people) {
            ok += h >= k ? 1 : 0;
        }
        System.out.println(ok);
    }
}

Measured memory_bytes: 47568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    vector<ll> A(N);
    vector<ll> B(N-1);
    rep(i,N-1)cin>>B[i];
    A[0] = B[0];
    A[N-1] = B[N-2];
    rep1(i,N-1){
        A[i] = min(B[i-1],B[i]);
    }
    print(A);
    ll ans = 0;
    rep(i,N)ans+=A[i];
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &&i : a) scanf("%d", &i);
    auto dp = make_v(n+1, n+1, 0LL);
    // dp[i][j] 区間[i, j)が残ったときのスコア
    for (int x = 1; x <= n; ++x) {
        for (int i = 0; i < n; ++i) {
            int j = i+x;
            if(j > n) break;
            if((n-x)%2 == 0){
                dp[i][j] = -INF<ll>;
                if(i+1 < n) dp[i][j] = max(dp[i][j], dp[i+1][j]+a[i]);
                if(j >= 1) dp[i][j] = max(dp[i][j], dp[i][j-1]+a[j-1]);
            }else {
                dp[i][j] = INF<ll>;
                if(i+1 < n) dp[i][j] = min(dp[i][j], dp[i+1][j]-a[i]);
                if(j >= 1) dp[i][j] = min(dp[i][j], dp[i][j-1]-a[j-1]);
            }
        }
    }
    cout << dp[0][n] << "\n";
    return 0;
}


Measured memory_bytes: 72704
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    string s;
    cin >> s;
    for (char x : s) if (x == '7') {
        cout << "Yes";
        return;
    }
    cout << "No";
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

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

  int s, c;
  int str[n];
  rep (i, n) {
    str[i] = -1;
  }
  int flag = true;

  rep (i, m) {
    cin >> s >> c;
    if (str[s - 1] == -1) str[s - 1] = c;
    else {
      if (str[s - 1] != c) flag = false;
    }
  }

  // rep(i, n) {
  //   cout << str[i];
  // }
  // cout << endl;

  if (!flag) cout << -1 << endl;
  else {
    if (n == 1 && (str[0] == 0 || str[0] == -1)) cout << 0 << endl;
    else if (str[0] == 0) cout << -1 << endl;
    else {
        rep(i, n) {
        if (i == 0 && str[i] == -1) cout << 1;
        else if (str[i] == -1) cout << 0;
        else cout << str[i];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a,b;
char s[100002];
inline bool check(re int x,re int y){
	re int mid=x+y>>1;
	for(re int i=x,j=y;i<=j;++i,--j)if(s[i]!=s[j])return 0;
	return 1;
}
signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(check(1,n)&&check(1,n/2)&&check(n/2+2,n))puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  int sum = 0;
  for (int i=0; i<M; i++){
    cin >> s.at(i);
    sum += s.at(i);
  }
  if (N < sum){
    cout << "-1" << endl;
    return 0;
  }
  cout << N - sum << endl;
  return 0;
}
  

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

int main()
{
  int n;
  cin >> n;
  int tp = 0, hp = 0;
  for (int i=0; i<n; i++) {
    string taro, hanako;
    cin >> taro >> hanako;
    if (taro > hanako) tp += 3;
    else if (taro < hanako) hp += 3;
    else {
      tp++; hp++;
    }
  }
  cout << tp << ' ' << hp << endl;
  return 0;
}



Measured memory_bytes: 3168
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

d = {"r": p, "s": r, "p": s}  # key: value = 筐体が出す手: 勝つともらえる点数
ans = 0
wins = [False] * k  # 剰余の周期ごとに、前回の勝ち負けを管理。勝ってたらTrueにして次回は負けないといけない。

for i in range(n):
    # kの剰余を使って周期ごとに管理。例えば剰余１の周期だけ見ると、出す手がずっと同じだと○×○×となる。
    # 出す手が前と異なるときは気にせず点数を追加する。
    if not wins[i % k] or t[i] != t[i-k]:
        ans += d[t[i]]
        wins[i % k] = True
    else:
        wins[i % k] = False

print(ans)

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

int main(){
	int N;
	int count;
	int num;
	int a[100001];
	
	cin >> N;
	for(int i=0; i<N; ++i){
		cin >> a[i];
	}
	
	sort(a, a+N);
	num=a[0];
	++count;
	
	for(int i=1; i<N; ++i){
		if(a[i]!=num){
			++count;
			num=a[i];
		}
	}
	
	if(count%2 == 0) cout << --count << endl;
	else cout << count << endl;
	
	return 0;
}

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

int main() {
  int DIV = 1e+9 + 7;
  long N, K; cin >> N >> K;
  long sum = 0;
  for (long k = K; k <= N+1; k++) {
    sum += k*(N+1-k)+1; sum %= DIV;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 2000000000;
// const ll MOD = 1000000007;

int N;
string S;

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

  vector<int> b_sum(N + 1, 0);
  vector<int> w_sum(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    if (S[i - 1] == '#') {
      b_sum[i] = b_sum[i - 1] + 1;
      w_sum[i] = w_sum[i - 1];
    } else {
      b_sum[i] = b_sum[i - 1];
      w_sum[i] = w_sum[i - 1] + 1;
    }
  }

  int ans = INF;
  for (int i = 0; i <= N; i++) {
    int sum = (b_sum[i] - b_sum[0]) + (w_sum[N] - w_sum[i]);
    ans = min(ans, sum);
  }

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

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

using namespace std;
int a,b,c,d,x[1000],y[1000];
int main()
{
    cin>>a>>b>>c>>d;
    for(int i=0;i<a;i++)
    {
     cin>>x[i];
    }
    sort(x,x+a);
    for(int i=0;i<b;i++)
    {
        cin>>y[i];
    }
    sort(y,y+b);
    if(x[a-1]<y[0]&&x[a-1]<d&&y[0]>c)
    {
        cout<<"No War";
    }else
    {
        cout<<"War";
    }
    return 0;
}


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

int main() {
  int N,M;
  cin>>N;
  vector<string>s(N);
  vector<int>a(N+1);
  for(int i=0;i<N;i++){
    cin>>s[i];
    a[i]=0;
  }
  cin>>M;
  vector<string>t(M);
  for(int i=0;i<M;i++){
    cin>>t[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(s[i]==s[j])a[i]++;
      }
    for(int j=0;j<M;j++){
      if(s[i]==t[j])a[i]--;
    }
  }
  a[N]=0;
  cout<<*max_element(a.begin(),a.end())<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long int a,b,c=0;
  scanf("%lld %lld",&a,&b);
  if(a*2<=b){
    c+=a;
    b-=a*2;
  }else{
    c+=b/2;
    b-=c*2;
  }
  c+=b/4;
  printf("%lld",c);
  return 0;}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static boolean allEven(List<Integer> a) {
		for (int x : a) {
			if (x % 2 != 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Integer> array = new ArrayList<>();
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(sc.next());
			array.add(x);
		}

		while(allEven(array)) {
			int i = 0;
			for (int x : array) {
				array.set(i, x / 2);
				i++;
			}
			cnt++;
		}
		System.out.println(cnt);
	}
}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (a.at(i) > a.at(i - 1)) {
      for (i; i < n; i++) {
        if (a.at(i) < a.at(i - 1)) {
          cnt++;
          break;
        }
      }
    } else if (a.at(i) < a.at(i - 1)) {
      for (i; i < n; i++) {
        if (a.at(i) > a.at(i - 1)) {
          cnt++;
          break;
        }
      }
    }
  }

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

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

#define int long long

using namespace std;

const int maxn = 1e5 + 10;
int dp_up[maxn], dp_down[maxn], n, mod;
vector<int> adj[maxn];

int dfs_up(int u = 1, int par = 0)
{
    (++(dp_up[u] *= dp_up[par])) %= mod;
    int p = 1;
    for (int v : adj[u])
        if (v != par)
            (dp_up[v] *= p) %= mod, (p *= dp_down[v] + 1) %= mod;
    reverse(adj[u].begin(), adj[u].end());
    p = 1;
    for (int v : adj[u])
        if (v != par)
            (dp_up[v] *= p) %= mod, (p *= dp_down[v] + 1) %= mod;
    for (int v : adj[u])
        if (v != par)
            dfs_up(v, u);
}

int dfs_down(int u = 1, int par = 0)
{
    dp_down[u] = 1;
    for (int v : adj[u])
        if (v != par)
            (dp_down[u] *= dfs_down(v, u) + 1) %= mod;
    return dp_down[u];
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> mod;

    fill(dp_up + 1, dp_up + maxn, 1);
    for (int i = 0, u, v; i < n - 1; i++)
        cin >> u >> v, adj[u].push_back(v), adj[v].push_back(u);
    dfs_down();
    dfs_up();

    for (int i = 1; i <= n; i++)
        cout << dp_up[i] * dp_down[i] % mod << '\n';

    return 0;
}


Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define itn int

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long ans = 0;
    int n, K;
    cin >> n >> K;
    vector<int> vs(n);
    for (int i = 0; i < n; i++) cin >> vs[i];
    for (int i = 0; i <= min(n, K); i++) {
        // 取る数
        for (int j = 0; j <= i; j++) {
            // 左から
            vector<int> get;
            for (int k = 0; k < j; k++) {
                get.push_back(vs[k]);
            }
            for (int k = 0; k < i - j; k++) {
                get.push_back(vs[n - 1 - k]);
            }
            assert(get.size() == i);

            sort(get.begin(), get.end());
            long long sum = accumulate(get.begin(), get.end(), 0ll);
            ans = max(ans, sum);
            for (int k = 0; k < min((int) get.size(), K - i); k++) {
                // 戻す数
                sum -= get[k];
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = (ll)1e9 + 7;
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)

signed main() {
	ll N;
	cin>>N;
	vector<ll> a(N,0);
	rep(i,N){
		cin>>a[i];
	}

	vector<vector<ll>> position(200001);
	rep(i,N){
		position[a[i]].push_back(i);
	}

	vector<ll> dp(N+1,0);
	dp[0]=1;
	rep(i,N){
		dp[i+1]=dp[i];

		auto it=lower_bound(position[a[i]].begin(), position[a[i]].end(), i);
		if(it!=position[a[i]].begin()){
			ll t=*it;
			it--;
			ll s=*it;
			if(t-s>1)dp[i+1]+=dp[s+1];
		}
		dp[i+1]%=MOD;
	}
	cout<<dp[N]<<endl;

	return 0;
}


Measured memory_bytes: 14336
import sys
import math

input = sys.stdin.readline
N=int(input())
A = [int(input()) for i in range(N)]
mod = 998244353

S = sum(A)
maxA = max(A)
dp = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
dp[0][S-math.ceil(S/2)]=1
for i in range(1,N+1):
  for j in range(S+1-math.ceil(S/2)):
    dp[i][j] = (dp[i-1][j+A[i-1]]*2 + dp[i-1][j])%mod
bad_r = sum(dp[N])

if S%2 == 0:
  dp2 = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
  dp2[0][S-math.ceil(S/2)]=1
  for i in range(1,N+1):
    for j in range(S+1-math.ceil(S/2)):
      dp2[i][j] = (dp2[i-1][j+A[i-1]] + dp2[i-1][j])%mod
  bad_rg = dp2[N][0]
else:
  bad_rg = 0
  
ans = 3**N - bad_r*3 + bad_rg*3
print(ans%mod)

Measured memory_bytes: 246408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1e9 + 7;

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

    ll low = 0, high = 0;
    ll ret = 1;
    for (int i = 0; i < n; i++) {
        low += i, high += n - i;
        if (i + 1 >= k) ret += high - low + 1, ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import collections
import math

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

dp = [0]

for i in range(lenums):
    dp.append(dp[i] + nums[i])

count_dict = collections.Counter(dp)
for i in count_dict.values():
    if i <= 1:
        continue
    answer = answer + i * (i - 1) // 2 # xC2

print(answer)


Measured memory_bytes: 41564