akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array

strToInt s = (read :: String -> Int)

main = do

   n <- readLn :: IO Int
   an <- replicateM n (readLn :: IO Int)
   let bn = map length (group (sort an))
   let cn = filter (odd) bn
   print (length cn)

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

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> ans;
	ans.insert(a);
	ans.insert(b);
	ans.insert(c);
	if( ans.size()==2 ) {
		cout << "Yes";
	}else {
		cout << "No";
	}
	
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n,k;cin>>n>>k;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }

    if((n-1)%(k-1)==0){
        cout<<(n-1)/(k-1)<<endl;
        return 0;
    }

    cout<<(n-1)/(k-1)+1<<endl;
}



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

int main()
{
	while(true){
		int H;
		cin >> H;

		if(H==0)
			break;

		int S[10][5];			// 石の並び
		for(int y=0; y<H; y++)
			for(int x=0; x<5; x++)
				cin >> S[y][x];

		int sco = 0;			// スコア

		while(true){
			bool flg = false;

			for(int y=0; y<H; y++){			// 消滅のステップ
				int m = S[y][2];
				if(m==0)
					continue;

				if(S[y][0]==m && S[y][1]==m){			// 0～2が同じ
					sco += m*3;  S[y][0] = S[y][1] = S[y][2] = 0;  flg = true;
					if(S[y][3]==m){
						sco += m;  S[y][3] = 0;
						if(S[y][4]==m){
							sco += m;  S[y][4] = 0;
						}
					}
				}
				else if(S[y][1]==m && S[y][3]==m){		// 1～3が同じ
					sco += m*3;  S[y][1] = S[y][2] = S[y][3] = 0;  flg = true;
					if(S[y][4]==m){
						sco += m;  S[y][4] = 0;
					}
				}
				else if(S[y][3]==m && S[y][4]==m){		// 2～4が同じ
					sco += m*3;  S[y][2] = S[y][3] = S[y][4] = 0;  flg = true;
				}
			}

			if(!flg)
				break;

			for(int x=0; x<5; x++){			// 落下のステップ
				for(int y=H-1; y>=0; y--){
					if(S[y][x]!=0)
						continue;

					for(int y2=y-1; y2>=0; y2--){		// 空きより上を探す
						if(S[y2][x]!=0){
							S[y][x] = S[y2][x];  S[y2][x] = 0;  break;
						}
					}
				}
			}
		}

		cout << sco << endl;
	}

	return 0;
}



Measured memory_bytes: 3012
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
vector<int> dat;


//inputします
void input() {
    cin >> n;
    dat.resize(n);
    ff(i, 0, n) {
        cin >> dat[i];
    }
}

//ライブラリ置き場

//main
int main() {
    input();
    int ans = 1;
    int min = dat[0];
    ff(i, 1, n) {
        if (dat[i] <= min) {
            ans++;
            min = dat[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(int i=0;i<n;i++){
        if(a[i]==i){
            if(i==n-1){
                swap(a[i],a[i-1]);
            }else{
                swap(a[i],a[i+1]);
            }
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}


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

int main()
{
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

Measured memory_bytes: 3632
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
n,a,b=mi()
c=pow(2,n,mod)-1
fact=[1]*(2*10**5+1)
for i in range(1,2*10**5+1):
  fact[i]=(fact[i-1]*i)%mod
def nCk(n,k):
  h=1
  for i in range(k):
    h=(h*(n-i))%mod
  x=h*pow(fact[k],mod-2,mod)
  return(x)
print((c-nCk(n,a)-nCk(n,b))%mod)

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

vector<string> divide ={"dream","dreamer","erase","eraser"};

int main(){
  string S;
  cin >> S;
  
  vector<int> dp(S.size()+1);
  dp.at(0) = 1;
  
  for(int i=0; i<S.size(); i++){
    if(dp.at(i) == 0){
      continue;
    }
    
    for(string s:divide){
      if(S.substr(i,s.size()) == s){
        dp.at(i+s.size()) = 1;
      }
    }
  }
  
  if(dp.at(S.size()) == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k,c;
  cin >> n >> k >> c;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  string s;
  cin >> s;
  vector<pair<int,int>> p(n);
  vector<pair<int,int>> q(n);
  if(s[0]=='o')p[0]=make_pair(1,0);
  else p[0]=make_pair(0,c);
  if(s[n-1]=='o')q[n-1]=make_pair(1,0);
  else q[n-1]=make_pair(0,c);
  rep(i,n-1){
    int y=i;
    if(p[y].second>=c&&s[y+1]=='o')p[y+1]=make_pair(p[y].first+1,0);
    else p[y+1]=make_pair(p[y].first,p[y].second+1);
  }
  rep(i,n-1){
    int y=n-1-i;
    if(q[y].second>=c&&s[y-1]=='o')q[y-1]=make_pair(q[y].first+1,0);
    else q[y-1]=make_pair(q[y].first,q[y].second+1);
  }
  //rep(i,n)cout << q[i].first << " " << q[i].second << endl;
  if(q[1].first<k)cout << 1 << endl;
  rep(i,n-2){
    if(p[i].first+q[i+2].first<k)cout << i+2 << endl;
  }
  if(p[n-2].first<k)cout << n << endl;
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))
#define MAXN 110

int v[MAXN];
int n;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	string s;
	int cont=0;
	
	cin >> s;
	
	for(char c: s)
		if(c == '2')
			cont++;
			
	cout << cont << endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,k; cin>>n>>k;
	ll h[n+1]; forn1(i,n) cin>>h[i];
	ll dp[n+1]; dp[0] = 0;
	dp[1] = 0;
	for(int i=2;i<=n;i++)
	{
	    dp[i] = 1e18;
	    for(int j=i-1;j>=max(1,i-k);j--)
	        dp[i] = min( dp[i] , dp[j] + abs(h[i]-h[j]) );
	}
	cout<<dp[n];
	
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define watch1(x) cout<<(#x)<<" = "<<(x)<<"\n"
#define watch2(x , y) cout<<(#x)<<" = "<<(x)<<"  "<<(#y)<<" = "<<(y)<<"\n"
#define AC_ISA ACCEPTED--
#define CFT int ACCEPTED = 1
#define MYT int ACCEPTED = 1000
#define write_to_file() freopen("output.txt" , "w" , stdout)
#define GeoOutputFix(VV) cout<<fixed<<setprecision(VV)
typedef long long lld;
typedef pair<lld, lld> dd;
typedef complex<long double> point;
#define X real()
#define Y imag()
#define dist(a , b) sqrt(pow(a.X - b.X , 2) + pow(a.Y- b.Y , 2))
int dr[] = {1 , 1 , 1 , 0 , 0 , -1 , -1 , -1};
int dc[] = {-1 , 0 , 1 , -1 , 1 , -1 , 0 , 1};
int ddr[] = {1 , 0 , 0 , -1};
int ddc[] = {0 , -1 , 1 , 0};
int SD(){int i ;scanf("%d", &i);return i;}
lld SLL(){lld i;scanf("%lld", &i);return i;}
char SC(){char i;scanf(" %c", &i);return i;}
const double PI = acos(-1);
const int AKA = 1e6+6 , N = 1e3 + 3;
int cm[AKA] , a[AKA];
char s[AKA];
int main ()
{
    //write_to_file();
    int n = SD() , q = SD();
    for(int i = 1 ; i  <= n ; ++i)
        s[i] = SC();
    for(int i = 2 ; i <= n ; ++i)
    {
        if(s[i - 1] == 'A' && s[i] == 'C')
            cm[i] = cm[i - 1] + 1;
        else
            cm[i] = cm[i - 1];
    }
    while(q--)
    {
        int l = SD() , r = SD();
        cout<<cm[r] - cm[l]<<"\n";

    }
}
/*

                                       ███████████████████████████
                                       ███████▀▀▀░░░░░░░▀▀▀███████
                                       ████▀░░░░░░░░░░░░░░░░░▀████
                                       ███│░░░░░░░░░░░░░░░░░░░│███
                                       ██▌│░░░░░░░░░░░░░░░░░░░│▐██
                                       ██░└┐░░░░░░░░░░░░░░░░░┌┘░██
                                       ██░░└┐░░░░░░░░░░░░░░░┌┘░░██
                                       ██░░┌┘▄▄▄▄▄░░░░░▄▄▄▄▄└┐░░██
                                       ██▌░│██████▌░░░▐██████│░▐██
                                       ███░│▐███▀▀░░▄░░▀▀███▌│░███
                                       ██▀─┘░░░░░░░▐█▌░░░░░░░└─▀██
                                       ██▄░░░▄▄▄▓░░▀█▀░░▓▄▄▄░░░▄██
                                       ████▄─┘██▌░░░░░░░▐██└─▄████
                                       █████░░▐█─┬┬┬┬┬┬┬─█▌░░█████
                                       ████▌░░░▀┬┼┼┼┼┼┼┼┬▀░░░▐████
                                       █████▄░░░└┴┴┴┴┴┴┴┘░░░▄█████
                                       ███████▄░░░░░░░░░░░▄███████
                                       ██████████▄▄▄▄▄▄▄██████████
                                       ███████████████████████████
                             ▂▃▄▅▆▇█▓▒░Ahmed_Salah(Screaming Eagle)░▒▓█▇▆▅▄▃    */


Measured memory_bytes: 2944
n,k,q=map(int,input().split())
lis=[0]*n
for i in range(q):
  a=int(input())
  lis[a-1]+=1
for j in range(0,n):
  if k-q+lis[j]>0:
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 4680
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] sum = new long[N];	
		sum[0] = sc.nextLong();
		for(int i = 1; i < N; i++) {
			sum[i] = sum[i-1];
			sum[i] += sc.nextLong();
		}
		int cut = N-1;
		for(int i = 0; i < N; i++) {
			if(sum[i] >= sum[N-1]/2) {
				cut = i;
				break;
			}
		}
		long ans = 0;
		if(cut == 0)
			ans = sum[0]*2 - sum[N-1];
		else
			ans = Math.min(sum[cut]*2-sum[N-1], sum[N-1]-sum[cut-1]*2);
		System.out.println(ans);

	}

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n,m;
  cin >> n >> m;
  vector<vector<int>> v(n);
  rep(i,m){
    int a,b;cin >> a >> b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vector<int> res(n);
  vector<ll> dist(n,-1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  while(!que.empty()){
    int ov = que.front();que.pop();
    for(auto nv : v[ov]){
      if(dist[nv] != -1)continue;
      dist[nv] = dist[ov]+1;
      res[nv] = ov+1;
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int i =1;i < n;i++)cout << res[i] << endl;

  




  return 0;
}

Measured memory_bytes: 10920
#include <stdio.h>

int main(int argc, char **argv)
{
	char a, b, tmp = 'A';
	
	while(scanf("%c,%c", &a, &b) != EOF){		
		if(tmp == a){
			tmp = b;
		} else if(tmp == b){
			tmp = a;
		}
	}
	printf("%c\n", tmp);
	
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int t = max(a, max(b, c)) * 3 - a - b - c;
    if (t % 2 == 0)cout << t / 2 << endl;
    else cout << (t + 3) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
int n;
int a[maxn];
int main()
{
	scanf("%d",&n);
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==i)
			cnt++;
		else
		{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(cnt+1)/2;
	printf("%d\n",ans);
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      String a = scanner.next();
      String b = scanner.next();
      String c = scanner.next();

      int ans = 0;
      for (int i = 0; i < n; i++) {
        ans += solve(a.charAt(i), b.charAt(i), c.charAt(i));
      }
      System.out.print(ans);
    } finally {
      scanner.close();
    }
  }

  private static int solve(int a, int b, int c) {
    int ans = 2;
    if (a == b) ans--;
    if (a == c) ans--;
    if (b == c) ans--;
    if (ans < 0) ans = 0;
    return ans;
  }
}


Measured memory_bytes: 23764
MOD = 10**9 + 7
dp = {0: 1}

S = int(input())
for s in range(3, S+1):
  for term in range(3, s+1):
    if s - term < 0:
      break
    else:
      dp[s] = dp.get(s-term, 0) + dp.get(s, 0) % MOD

print(dp.get(S, 0))

Measured memory_bytes: 73712
from sys import stdin
input = stdin.readline

def solve():

    N = int(input())
    a = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    res = ((N+1)**2)*N//2-N*(N+1)*(2*N+1)//6
    for u,v in a:
        res -= min(u,v)*(N - max(u,v)+1)
    print(res)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 121548
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		double a[]=new double[n];
		for(int i=0;i<n;i++)
			a[i]=s.nextDouble();
		double dp[][]=new double[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				dp[i][j]=-1.0;
		System.out.println(String.format("%.10f", rec(0,0,a,n,dp)));
		
	}

	private static double rec(int i, int h, double[] a, int n, double[][] dp) {
		
		if(i==n) {
			if(h>=(n+1)/2)
				return 1.0;
			else
				return 0.0;
		}
		if(dp[i][h]!=-1) return dp[i][h];
		double op1=a[i]*rec(i+1, h+1, a, n, dp);
		double op2=(1-a[i])*rec(i+1, h, a, n, dp);
		
		
		return dp[i][h]=op1+op2;
		
	}
	
}

Measured memory_bytes: 118396
#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 a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
  return 0;
}


Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	ll n; cin >> n; n++;
	int cnt = 0;
	for (ll x = 1; x < n; x <<= 1) cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  int ans = 0;
  cin >> n;
  
  if (n % 1000 == 0) {
    cout << "0\n";
  }else {
    while (ans < n) {
      ans += 1000;
    }
    cout << ans - n << "\n";
  }
  
  return 0;
}


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

#define MAX_V 100001
#define MAX_E 100001

vector<pair<int, int>> G[MAX_V];
int color[MAX_V];

bool dfs(int v, int c)
{
    //printf("%d %d\n", v, c);
    color[v] = c + 1;
    for (int i = 0; i < G[v].size(); i++)
    {
        if (color[G[v][i].first] == 0) // not visited
        {
            dfs(G[v][i].first, c ^ G[v][i].second);
        }
    }
}

int main()
{

    int n;
    int u, v, w;

    cin >> n;

    for (int i = 1; i <= n - 1; i++)
    {
        cin >> u >> v >> w;
        G[u].push_back(make_pair(v, w % 2));
        G[v].push_back(make_pair(u, w % 2));
    }

    dfs(1, 0);
    for (int i = 1; i <= n; i++)
    {
        cout << color[i] - 1 << endl;
    }
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	vector<vector<int>> probs(3);

	for (int i = 0; i < N; i++)
	{
		int p;
		cin >> p;

		if (p <= A)
		{
			probs[0].push_back(p);
		}
		else if (p <= B)
		{
			probs[1].push_back(p);
		}
		else
		{
			probs[2].push_back(p);
		}
	}

	cout << min(probs[0].size(), min(probs[1].size(), probs[2].size())) << endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    double ans = 0.0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int x = n-1, y = n-2;
            while(x==i || x==j) x--;
            while(y==i || y==j || y==x) y--;
            ans = max(ans, double(a[x]+a[y])/(a[j]-a[i]));
        }
    }
    printf("%.8lf\n",ans);
    return 0;
}



Measured memory_bytes: 3280
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let ss = read_line();
    let mut res = 700;
    for c in ss.chars() {
        if c == 'o' {
            res += 100;
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;



int main() {
  string S; cin >> S;
  int l = S.length();
  ll dp[l+1][13]={}; dp[0][0] = 1;
  rep(i,l) {
    if (S[i]=='?') {
      rep(j,13) rep(k,10) {
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= MOD;
      }
    }
    else {
      int num = S[i]-'0';
      rep(j,13) {
        dp[i+1][(j*10+num)%13] += dp[i][j];
        dp[i+1][(j*10+num)%13] %= MOD;
      }
    }
  }
  // rep(i,13) cout << dp[l][i] << " "; cout << endl;
  ll result = dp[l][5];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int H, W, K;
    cin >> H >> W >> K;
    string c[H];
    for (int i = 0; i < H; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < (1<<H); i++) {
        for (int j = 0; j < (1<<W); j++) {
            int cnt = 0;
            for (int k = 0; k < H; k++) {
                if ((i & (1<<k)) != 0) continue;
                for (int l = 0; l < W; l++) {
                    if ((j & (1<<l)) != 0) continue;
                    if (c[k][l] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  a.pb(1);
  int64 cur = 1000;
  int32 pre = a[0];
  REP(i,n){
    if(a[i] > a[i+1]){
      cur = cur % pre + cur / pre * a[i];
      pre = a[i+1];
    }
  }
  ANS(cur);
  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
# define    PI                  3.14159265358979323846

int main()
{
    ll k,n,i;
    cin>>k>>n;
    ll sum=0;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    ll ans = k-sum;
    if(ans<0)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3700
n, a, b, c, d = gets.split.map(&:to_i)
s = gets.strip
over = false
for i in (b - 1)...d
  if s[i] == '#' && s[i + 1] == '#'
    puts 'No'
    exit
  end

  over = true if s[i] == '.' && s[i + 1] == '.' && s[i - 1] == '.'
end

if d < c
  if !over
    puts 'No'
    exit
  end
end

for i in (a - 1)...c
  if s[i] == '#' && s[i + 1] == '#'
    puts 'No'
    exit
  end
end

puts 'Yes'



Measured memory_bytes: 2172
import sys
input = sys.stdin.readline
n = int(input())
num = list(map(int, input().split()))
mod = 10**9+7
num = tuple(num)

from collections import Counter
def factorization(a):
        yy, j = [], 2
        y = yy.append
        while(a > 1):
            for i in range(j, int(a**0.5)+1):
                if a % i == 0:
                    y(i)
                    a, j = a//i, i
                    break
            else:
                y(a)
                break
        return Counter(yy)
      
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret
  
lcd = dict()
for i in num:
  j = primeFactor(i)
  for x,y in j.items():
    if not x in lcd.keys():
      lcd[x] = y
    else:
      lcd[x] = max(lcd[x],y)

lc = 1
for i,j in lcd.items():
  lc *= pow(i,j,mod)
  
ans =0
for i in range(n):
  ans += lc*pow(num[i], mod-2, mod)
  ans %= mod
print(ans)

Measured memory_bytes: 76240
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int A, B, C, D, K;
	cin >> A >> B >> C >> D >> K;

	int hun = D - B + 60 * (C - A) - K;

	co(hun);



	Would you please return 0;
}

Measured memory_bytes: 3636
//https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b
//B - K個のケーキ / K Cakes
#include <bits/stdc++.h>
using namespace std;
//using ll=int64_t;
using ll=long long int;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
#if 0
    long long int lli;
    long int li;
    int64_t i64t;
    dump(sizeof(long long int));
    dump(sizeof(long int));
    dump(sizeof(int64_t));
    dump(std::is_same<int64_t, long int>::value);
    dump(std::is_same<int64_t, long long int>::value);
    return 0;
#endif
    ll K, T; cin>>K>>T;
    vector<pair<ll,ll>> at(T+1); //数,index
    FOR(i,1,T+1){
        cin>>at.at(i).first;
        at.at(i).second=i;
    }
    sort(at.begin(),at.end(),greater<pair<ll,ll>>());
    ll ans=max(at.begin()->first-1-(K-at.begin()->first),0LL);
    cout<<ans<<endl;
#if 0
    priority_queue<pair<ll,ll>> que;
    FOR(i,1,T+1){
        que.push(at.at(i));
    }

    ll ans=0;
    ll prev=-1;
    REP(i,K){
        auto a=que.top();
        que.pop();
        if(prev!=a.second){
            a.first-=1;
            prev=a.second;
            ++ans;
        }else{
            if(!que.empty()){
                auto b=que.top();
                que.pop();
                if(prev!=b.second){
                    b.first-=1;
                    prev=b.second;
                    ++ans;
                }
                if(b.first>0)que.push(b);
            }
        }
        if(a.first>0)que.push(a);
    }
    cout<<K-ans<<endl;
#endif
    return 0;
}

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

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

int main() {
    int n,k;cin>>n>>k;
    int a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n,greater<int>());
    int ans=0;
    rep(i,k)ans+=a[i];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())
lsS = [1,1]+[0]*(N-1)
for i in range(M):
    lsS[int(input())] = -1
for i in range(2,N+1):
    if lsS[i] == -1:
        continue
    else:
        if lsS[i-2] != -1:
            lsS[i] += lsS[i-2]
        if lsS[i-1] != -1:
            lsS[i] += lsS[i-1]
        lsS[i] = lsS[i]%(10**9+7)
print(lsS[N])

Measured memory_bytes: 12568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


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

  vector<vector<char>> N(n,vector<char>(n));
  vector<vector<char>> M(m,vector<char>(m));

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> N[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < m; j++){
      cin >> M[i][j];
    }
  }

  bool fin = true;
  for(int i = 0; i < (n - m + 1); i++){
    for(int j = 0; j < (n - m + 1); j++){
      bool f = false;
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(N[k + i][l + j] != M[k][l]){
            f = true;
            break;
          }
          if(k == m - 1 && l == m - 1){
            fin = false;
            cout << "Yes" << endl;
          }
        }
        if(f){break;}
      }
      if(fin == false){
        break;
      }
    }
    if(fin == false){
        break;
      }
  }
  if(fin){cout << "No" << endl;}
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [['#' for _ in range(w+2)]]
for _ in range(h):
    s.append(list('#' + input() + '#'))
s.append(['#' for _ in range(w+2)])

# WFS
ans = []
d = [(1,0), (0,1), (-1,0), (0,-1)]
from collections import deque
for i in range(1, h+1):
    for j in range(1, w+1): # start = s[i][j]
        if s[i][j] == '#':
            continue
        seen = [[-1 for _ in range(w+2)] for __ in range(h+2)]
        seen[i][j] = 0
        todo = deque([(i, j)])
        num = 0
        while todo != deque([]):
            x, y = todo.popleft()
            for k in d:
                xk = x + k[0]
                yk = y + k[1]
                if seen[xk][yk] == -1 and s[xk][yk] == '.':
                    num = seen[x][y] + 1
                    seen[xk][yk] = num
                    todo.append((xk,yk))
        ans.append(num)
print(max(ans))

Measured memory_bytes: 3444
import sys

N = int(input())

if N == 1:
    print(1)
    sys.exit()

ans = 0
count_max = 0
for i in range(1, N+1):
    count = (i ^ (i-1)).bit_length() - 1
    if count_max < count:
        count_max = count
        ans = i

print(ans)

Measured memory_bytes: 9040
using System;
using static System.Console;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(ReadLine());
		string[] ST = new string[N];
		ST = ReadLine().Split(' ');
		string S = ST[0];
		string T = ST[1];
		string result = "";
		for(int i = 0;i < N;i++)
		{
			result = string.Concat(result, S[i]);
			result = string.Concat(result, T[i]);
		}
		WriteLine(result);
	}
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    ll m = max(0LL,n-k);
    ll ans=x*min(k,n)+m*y;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import sys
import copy
from collections import deque
import time
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def bfs(board, H, W):
    is_visit = [[False for j in range(W)] for i in range(H)]
    move_list = [(1,0),(-1,0),(0,1),(0,-1)]
    now_pos_list = deque([((0, 0), 1)])
    while 1:
        if len(now_pos_list) <= 0:
            return -1;

        pos = now_pos_list.popleft()
        if pos[0][0] == H -1 and pos[0][1] == W -1:
            return pos[1]

        for move in move_list:
            new_y = pos[0][0] + move[0]
            new_x = pos[0][1] + move[1]
            if new_x >= 0 and new_y >= 0 and  new_x < W and new_y < H:
                if board[new_y][new_x] == "." and is_visit[new_y][new_x] == False:
                    is_visit[new_y][new_x] = True
                    now_pos_list.append(((new_y, new_x), pos[1] + 1))


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    board =[]
    for i in range(H):
        input_raw = read_func().strip()
        board.append(input_raw)
    black_num = 0
    for i in range(H):
        for j in range(W):
            if board[i][j] == "#":
                black_num += 1

    score = bfs(board, H, W)
    if score < 0:
        print -1
    else:
        print H * W - black_num - score


if __name__ == '__main__':
    main()


Measured memory_bytes: 3052
N = int(input())
first_last= [[0] * 10 for _  in range(10)]

for i in range(1,N + 1):
    s = str(i)
    f  =int(s[0])
    l = int(s[-1])
    first_last[f][l] += 1
# print(first_last)
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += first_last[i][j] * first_last[j][i]
print(ans)

Measured memory_bytes: 40632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using ll = long long;

int main(){
    ll h, w;
    std::cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0){
        std::cout << 0 << std::endl;
        return 0;
    }

    ll r;

    // 横で最初に分割
    ll minCost = 1000000000000;
    r = w % 2;
    for(ll i = 1; i <= h / 2; i++){
        ll s_tmp = i * w;
        ll s_other1 = (h - i) * ((w + r) / 2);
        ll s_other2 = (h - i) * ((w - r) / 2);
        ll tmpCost = std::max({s_tmp, s_other1, s_other2}) - std::min({s_tmp, s_other1, s_other2});
        minCost = std::min(tmpCost, minCost);
    }

    // 縦で最初に分割
    r = h % 2;
    for(ll j = 1; j <= w / 2; j++){
        ll s_tmp = j * h;
        ll s_other1 = (w - j) * ((h + r) / 2);
        ll s_other2 = (w - j) * ((h - r) / 2);
        ll tmpCost = std::max({s_tmp, s_other1, s_other2}) - std::min({s_tmp, s_other1, s_other2});
        minCost = std::min(tmpCost, minCost);
    }

    std::cout << std::min({minCost, h, w}) << std::endl;
    return 0;
}


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

using namespace std;

int main() {
  int n, a, b, c, d;
  char s[3] = {'+', '+', '+'};
  bool op[2] = {true, false};
  scanf("%d", &n);
  a = n / 1000;
  b = n % 1000 / 100;
  c = n % 1000 % 100 / 10;
  d = n % 1000 % 100 % 10;
  for (int i = 0; i < 2; i++) {
    s[0] = op[i] ? '+' : '-';
    for (int j = 0; j < 2; j++) {
      s[1] = op[j] ? '+' : '-';
      for (int k = 0; k < 2; k++) {
        s[2] = op[k] ? '+' : '-';
        for (int m = 0; m < 4; m++) {
          int tmp = a;
          op[i] ? tmp += b : tmp -= b;
          op[j] ? tmp += c : tmp -= c;
          op[k] ? tmp += d : tmp -= d;
          if (tmp == 7) goto END;
        }
      }
    }
  }
END:
  printf("%d%c%d%c%d%c%d=7\n", a, s[0], b, s[1], c, s[2], d);
  return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int main()
{
    FAST
    int n,m,k;
    cin>>n>>m>>k;
    char arr[n][m];
    for(int i=0;i<n;i++){
        string h;
        cin>>h;
        for(int j=0;j<m;j++){
            arr[i][j]=h[j];
        }
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int cnt=0;
            for(int ii=0;ii<n;ii++){
                for(int jj=0;jj<m;jj++){
                    if((i & (1<<ii)) || (j & (1<<jj))) continue;
                    if(arr[ii][jj]=='#')
                        cnt++;
                }
            }
            if(cnt==k)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){ 
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> cum(n+1,0);
  rep(i,n) cum[i + 1] = cum[i] + a[i];
  ll res = 0;
  map<ll,int> mp;
  for (int r = 0; r <= n; r++) {
    int l = max(0,r - k);
    if (r - l >= k) mp[(cum[l] - l + k) % k]--; 
    res += mp[(cum[r] - r + k) % k];
    mp[(cum[r] - r + k) % k]++;
  }
  cout << res << endl;
  return 0; 
} 

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    int N;
    cin>>N;
    vector<queue<int>> A(N);

    rep(i,N){
        rep(k,N-1){
            int temp;
            cin>>temp;
            temp--;
            A[i].push(temp);
        }
    }

    int ans=0;
    vector<int> look(N);
    rep(i,N){
        look[i]=i;
    }
    while(true){
        vector<int> looktemp;
        vector<bool> b(N,false);
        for(int l:look){
            if(b[l]||A[l].empty()){continue;}

            int q=A[l].front();
            if(!b[q]&&A[q].front()==l){
                b[l]=true;
                b[q]=true;
                looktemp.push_back(l);
                looktemp.push_back(q);
                A[l].pop();
                A[q].pop();
            }
        }
        if(looktemp.empty()){break;}
        ans++;
        look=looktemp;
    }
    rep(i,N){
        if(!A[i].empty()){
            ans=-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
const int maxn=1000000;
using namespace std;
 /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif*/
int main()

{ 
#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif  
   string s;
   cin>>s;
   int nb=0;
   int x=0;
   for(int i=0;i<3;i++)
   {
   	  if(s[i]=='R')
   	  {
   	  	x++;
		 }
		 else
		 {
		 	nb=max(nb,x);
		 	x=0;
		 }
   }
   nb=max(nb,x);
   cout<<nb<<endl;
}

Measured memory_bytes: 3608
import numpy as np
import sys
import math
import collections
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

dR = collections.defaultdict(int)
dL = collections.defaultdict(int)

ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1 

    dR[r] += 1

    ans += dL[r]

    dL[l] += 1  

print(ans)

Measured memory_bytes: 112988
import copy

while 1:
    n = list(input())
    if n == ["0", "0", "0", "0"]:
        break

    tmp = int(n[0])*1000 + int(n[1])*100 + int(n[2])*10 + int(n[3])
    if tmp % 1111 == 0:
        print("NA")
        continue

    cnt = 0
    while n != ["6", "1", "7", "4"]:
        n.sort(reverse=True)
        l = copy.deepcopy(n)
        n.sort()
        s = copy.deepcopy(n)
        l = int(l[0])*1000 + int(l[1])*100 + int(l[2])*10 + int(l[3])
        s = int(s[0])*1000 + int(s[1])*100 + int(s[2])*10 + int(s[3])
        n = list(str(l-s).zfill(4))
        cnt += 1

    print(cnt)



Measured memory_bytes: 6344
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
	vector<bool> p(1000000, true);
	p[0] = p[1] = false;
	for (int i = 2; i < 1000000; i++)
		if (p[i])
			for (int j = i * 2; j < 1000000; j += i)
				p[j] = false;
	for (;;) {
		int a, d, n; cin >> a >> d >> n;
		if (a == 0) break;
		for (int i = 0; i < n; i++) {
			while (!p[a]) a += d;
			a += d;
		}
		cout << a - d << endl;
	}
}

Measured memory_bytes: 1316
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
temp = 0
for _ in range(N):
    A = list(map(int, input().split()))
    for i in range(M):
        temp += A[i] * B[i]
    if temp + C > 0:
        cnt += 1
    temp = 0
print(cnt)

Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  A, B = readline() |> split |> parseArray

  result = if A>=13
    B
  elseif A>=6
    div(B,2)
  else
    0
  end

  println(result)
end

main()


Measured memory_bytes: 168640
#include "bits/stdc++.h"
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b==c||b+c==a||c+a==b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1):n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (long long i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (long long j = i * i; j <= n; j += i)
                if (!f[j]) f[j] = i;
        }
    }
    bool isPrime(int x) { return f[x] == x;}
};

int main() {
    cin.tie(0)->sync_with_stdio(false);

	Sieve sieve(1e5 + 1);
	vector<int> prime(1e5 + 1, 0);
	for (int i = 3; i < 1e5; i += 2) {
		int j = (i + 1) / 2;
		if (sieve.isPrime(i) && sieve.isPrime(j))
			prime[i] = 1;
	}

	vector<int> s(1e5 + 2, 0);
	for (int i = 1; i <= 1e5; i++)
		s[i] = s[i - 1] + prime[i];

	int q; cin >> q;
	REP(i, q) {
		int l, r; cin >> l >> r;
		cout << s[r] - s[l - 1] << '\n';
	}
    return 0;
}


Measured memory_bytes: 4408
#include <stdio.h>

int main(){
  int i,h,key[251];
  
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&key[i]);
  }
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,key[i]);
    
    if(i!=1)  printf("parent key = %d, ",key[i/2]);
    if(i*2<=h) printf("left key = %d, ",key[i*2]);
    if(i*2+1<=h)  printf("right key = %d, ",key[i*2+1]);
    
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>

int main()
{
    int N,i,sum=0,N0;

    scanf("%d",&N);
    N0 = N;

    i = 1;
    while(i<=N0){
        i *= 10;
        sum += N%10;
        N = N/10;
    }

    if(N0%sum==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
long long a,b,c,d,e;
int main()
{
	cin>>a>>b>>c;
    cout<<(a+b)*c/2;
	
	return 0;
}

Measured memory_bytes: 256