akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    map<string, int> mp;
    int n;
    cin >> n;
    rep(i, n){
        string str;
        cin >> str;
        mp[str]++;
    }
    cout << "AC" << " x " << mp["AC"] << endl;
    cout << "WA" << " x " << mp["WA"] << endl;
    cout << "TLE" << " x " << mp["TLE"] << endl;
    cout << "RE" << " x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  long long a, b, k; cin >> a >> b >> k;
  long long t = min(a, k);
  a -= t;
  k -= t;
  b -= min(b, k);
  cout << a << ' ' << b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
using namespace std;
const int N=1e5+5;
const int CN=1e6+5;
typedef pair<int,int> pii;

struct _ufs{
	int par[N],rnk[N];
	int fp(int x){
		if(x==par[x]) return x;
		else return par[x]=fp(par[x]);
	}
	void unit(int x,int y){
		x=fp(x);y=fp(y);
		if(rnk[x]<rnk[y]) par[x]=y;
		else{
			par[y]=x;
			if(rnk[x]==rnk[y]) rnk[x]++;
		}
	}
	void cl(int x){
		par[x]=x;
		rnk[x]=0;
	}
}ufs;

int n,m,cnt;
int use[N],id[N],dp[2*CN];
vector<pii> C[CN];
vector<int> nn[2*CN];
queue<int> q;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		x--;y--;
		C[z].push_back(pii(x,y));
	}
	for(int i=0;i<n;i++) ufs.cl(i);
	cnt=n;
	for(int i=0;i<CN;i++){
		if(C[i].empty()) continue;
		for(int j=0;j<C[i].size();j++){
			use[C[i][j].first]=use[C[i][j].second]=0;
			id[C[i][j].first]=id[C[i][j].second]=-1;
			ufs.cl(C[i][j].first);
			ufs.cl(C[i][j].second);
		}
		for(int j=0;j<C[i].size();j++) ufs.unit(C[i][j].first,C[i][j].second);
		for(int j=0;j<C[i].size();j++){
			pii pi=C[i][j];
			if(!use[pi.first]){
				int now=pi.first;
				use[now]=1;
				now=ufs.fp(now);
				if(id[now]==-1) id[now]=cnt++;
				nn[pi.first].push_back(id[now]);
				nn[id[now]].push_back(pi.first);
			}
			if(!use[pi.second]){
				int now=pi.second;
				use[now]=1;
				now=ufs.fp(now);
				if(id[now]==-1) id[now]=cnt++;
				nn[pi.second].push_back(id[now]);
				nn[id[now]].push_back(pi.second);
			}
		}
	}
	while(!q.empty()) q.pop();
	q.push(0);
	for(int i=1;i<cnt;i++) dp[i]=-2;
	while(!q.empty()){
		int now=q.front();
		q.pop();
		for(int i=0;i<nn[now].size();i++) if(dp[nn[now][i]]==-2){
			dp[nn[now][i]]=dp[now]+1;
			q.push(nn[now][i]);
		}
	}
	printf("%d\n",dp[n-1]/2);
	return 0;
}

Measured memory_bytes: 89472
line,col = map(int,input().split(" "))

list_col = [0 for i in range(col+1)]
for _ in range(line):
	#行ループ
	data = list(map(int,input().split(" ")))
	data.append(sum(data))
	print(*data)

	#列ループ
	for j in range(col+1):
		list_col[j] += data[j]

print(*list_col)




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

int main(){
  int n;
  cin >> n;
  if(n > 81){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 9;i > 0;i--){
    for(int j = 9;j >0 ;j--){
      if(n == i * j){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
	int w, h, n; cin >> w >> h >> n;
	int xmin = 0, xmax = w, ymin = 0, ymax = h;
	for (int i = 0; i < n; i++)
	{
		int x, y, a;
		cin >> x >> y >> a;
		if(a == 1) xmin = max(xmin, x);
		else if(a == 2) xmax = min(xmax, x);
		else if(a == 3) ymin = max(ymin, y);
		else if(a == 4) ymax = min(ymax, y);
	}
	if(xmin >= xmax || ymin >= ymax) cout << "0" << endl;
	else cout << (xmax - xmin) * (ymax - ymin) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	RF(c, s) { cout << (c == '?' ? 'D' : c); }
	cout << endl;
}


Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>

using namespace std;

#define ll long long 

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int A[n],B[n],C[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int i=0;i<n;i++)
		cin>>B[i];
	for(int i=0;i<n;i++)
		cin>>C[i];
	sort(A,A+n);	
	sort(C,C+n);
	ll count=0L;
	for(int i=0;i<n;i++)
	{
		int pos1=lower_bound(A,A+n,B[i])-A;
		
		if(pos1<0)
			pos1=0;
		// cout<<pos1<<endl;
		int pos2=upper_bound(C,C+n,B[i])-C;
		// cout<<B[i]<<" "<<pos2<<" pos2\n";
		if(pos2>=n)
			pos2=n;
		pos2=n-pos2;
		// cout<<pos1<<" "<<pos2<<" cou\n";
		count+=(ll)pos1*pos2;
	}
	cout<<count<<endl;
	return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int n;
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>s;
    n%=26;
    for(int i=0;i<s.size();i++){
        int d = numerize(s[i]);
        d+=n;
        if(d>26) d-=26;
        char z = char(d+64);
        s[i] = z;
    }
    cout<<s<<newl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int a,b;
  cin >> a >> b;
  P((a-b)+1);
}

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


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ll MAX_N=102;
ll n;
vld t(MAX_N),v(MAX_N);

ld f(ld x){
  ld res=LLINF;
  ld l=0;

  REP(i,n+2){
    ll r=l+t[i];
    if(x<l)
      res=min(res,v[i]+(l-x));
    if(l<=x && x<r)
      res=min(res,v[i]);
    if(r<=x)
      res=min(res,v[i]+(x-r));

    l+=t[i];
  }

  return res;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n;
  t[0]=0;
  REP(i,n)cin>>t[i+1];
  t[n+1]=0;

  v[0]=0;
  REP(i,n)cin>>v[i+1];
  v[n+1]=0;

  ld sum=0;
  REP(i,n+2)sum+=t[i];

  ld ans=0;
  ld pre=f(0);
  for(ld x=0.5; x<=sum; x+=0.5){
    ld now=f(x);
    ld area=(now+pre)*0.5/2;
    ans+=area;
    pre=now;
  }

  cout<<Decimal;
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
char table[8][9];
void solve(int a,int b){
	table[a][b]='0';
	for(int i=1;i<=3;i++){
		if(a-i>=0&&table[a-i][b]=='1')solve(a-i,b);
		if(b-i>=0&&table[a][b-i]=='1')solve(a,b-i);
		if(a+i<8&&table[a+i][b]=='1')solve(a+i,b);
		if(b+i<8&&table[a][b+i]=='1')solve(a,b+i);
	}
	return ;
}
int main(){
	int a;
	scanf("%d",&a);
	int now=0;
	while(a--){
		int b,c;
		for(int i=0;i<8;i++)scanf("%s",table[i]);
		scanf("%d%d",&b,&c);
		solve(c-1,b-1);
		printf("Data %d:\n",++now);
		for(int i=0;i<8;i++)printf("%s\n",table[i]);
	}
}

Measured memory_bytes: 0
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
result = ''

for b in B:
  if b in A1:
    a = A1.index(b)
    A1.remove(b)
    A1.insert(a, 0)
  elif b in A2:
    a = A2.index(b)
    A2.remove(b)
    A2.insert(a, 0)
  elif b in A3:
    a = A3.index(b)
    A3.remove(b)
    A3.insert(a, 0)
  else:
    pass


if A1.count(0) == 3:
  result ='y'
elif A2.count(0) == 3:
  result ='y'
elif A3.count(0) == 3:
  result ='y'

for m in range(3):
  if A1[m] == 0 and A2[m] == 0 and A3[m] == 0:
    result ='y' 
  else:
    pass


if A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
  result = 'y'
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
  result = 'y'


if result == 'y':
  print('Yes')
else:
  print('No')



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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int verticalLines = Integer.parseInt(str);
		int[] num = new int[verticalLines];
		for (int i = 0; i < verticalLines; i++) {
			num[i] = i + 1;
		}
		str = br.readLine();
		int horizontalLines = Integer.parseInt(str);
		for (int j = 0; j < horizontalLines; j++) {
			str = br.readLine();
			String[] edge = str.split(",", 2);
			int startingPoint = Integer.parseInt(edge[0]);
			int destination = Integer.parseInt(edge[1]);
			int temporary = num[destination - 1];
			num[destination - 1] = num[startingPoint - 1];
			num[startingPoint - 1] = temporary;
		}
		for (int number : num) {
			System.out.println(number);
		}
	}
}

Measured memory_bytes: 24036
n = int(input())
d = {}
while n % 2 == 0:
    d[2] = 1 if 2 not in d else d[2] + 1
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        d[f] = 1 if f not in d else d[f] + 1
        n //= f
    else:
        f += 2
if n != 1:
    d[n] = 1 if n not in d else d[n] + 1
cnt = 0
for k, v in d.items():
    i = 1
    while i <= v:
        cnt += 1
        v -= i
        i += 1
print(cnt)


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

#define i64 long long int

i64 n;

int main() {
	cin>>n;
	
	int ans = 1; // n
	int lim = 2;
	for(i64 i=2;i*i<=n;i++) {
		i64 t = n;
		while(t%i==0) t/=i;
		if(t%i==1) ans++;
		
		lim = i;
	}
	for(i64 i=1;n/i>lim;i++)
		if((n-1)%i==0) ans++;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n,x,t;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3652
n=int(input())
s_6=[6**(6-i) for  i in range(6)] 
s_9=[9**(5-i) for  i in range(5)]
amari=[0,1,2,3,4,5,1,2,3,1,2,3,2,3]

best=float("inf")
for i in range(n+1):
    count_6=0
    n_6=i
    for j in range(len(s_6)):
        count_6+=n_6//s_6[j]
        n_6=n_6%s_6[j]

    n_9=n-i
    count_9=0
    for j in range(len(s_9)):
        count_9+=n_9//s_9[j]
        n_9=n_9%s_9[j]

    best=min(best, count_6+count_9+ amari[n_6+n_9])

print(best)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

bool isok[100100];
int iserror[100100];
int N,M,p,ans,cnt;
string S;

int main(){
    cin>>N>>M;
    rep(i,100100){
        isok[i]=false;
        iserror[i]=0;
    }
    rep(i,M){
        cin>>p>>S;
        if(S=="AC"&&!isok[p-1]){
            isok[p-1]=true;
            cnt+=iserror[p-1];
        }
        else{
            iserror[p-1]++;
        }
    }
    rep(i,N){
        if(isok[i])ans++;
    }
    cout<<ans<<" "<<cnt<<endl;
    }

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == "snuke") {
                char tmp = 'A'-'a'+j+'a';
                cout << tmp << i+1 << endl;
                return 0;
            }
        }
    }
    return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import pprint

#fd = os.open('ITP1_1_D.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

n = int(input())

h = int(n / 3600)
n -= 3600 * h

m = int(n / 60)
n -= 60 * m

s = n

print('{}:{}:{}'.format(h, m, s))

Measured memory_bytes: 8244
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    V h(n);
    rep(i,n)cin>>h[i];
    sort(h.rbegin(),h.rend());
    ll ans=0;
    for(ll i=k;i<h.size();i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

int main(){
    
    // 1. 入力情報.
    int N, M, x;
    scanf("%d", &N);
    map<int, int> D, T;
    for(int i = 0; i < N; i++) scanf("%d", &x), D[x]++;
    scanf("%d", &M);
    for(int i = 0; i < M; i++) scanf("%d", &x), T[x]++;
    
    // 2. 新しい問題案作成せずに, 予選の問題セット完成できるか？
    bool ok = true;
    for(auto &t : T){
        if(t.S > D[t.F]){
            ok = false;
            break;
        }
    }
    
    // 3. 出力.
    if(ok) printf("%s\n", "YES");
    else   printf("%s\n", "NO");
    return 0;
    
}

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

signed main(){
  int N,X;
  cin>>N>>X;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(begin(A),end(A));
  int i=0,ans=0;
  while(X>=A[i]){
    if(i==N-1){
      if(A[i]==X)ans+=1;
      break;
    }
    X=X-A[i];
    i+=1;
    ans+=1;
  }
  cout<<ans<<endl;
}

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

int search(int x, int y, int k, int n, char** field) {
    int nx, ny;
    switch (k) {
    case 0:
        nx = x + 1;
        ny = y;
        break;
    case 1:
        nx = x + 1;
        ny = y + 1;
        break;
    case 2:
        nx = x;
        ny = y + 1;
        break;
    case 3:
        nx = x - 1;
        ny = y + 1;
        break;
    }
    if (0 <= nx && nx < n && 0 <= ny && ny < n && field[ny][nx] != '0') {
        return 1 + search(nx, ny, k, n, field);
    } else {
        return 1;
    }
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        char** field = new char* [n];
        for (int i = 0; i < n; i++) {
            field[i] = new char [n + 1];
        }
        for (int i = 0; i < n; i++) {
            cin >> field[i];
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (field[i][j] == '0') {
                    continue;
                }
                for (int k = 0; k < 4; k++) {
                    int length = search(j, i, k, n, field);
                    if (max < length) {
                        max = length;
                    }
                }
            }
        }
        cout << max << endl;
        for (int i = 0; i < n; i++) {
            delete[] field[i];
        }
        delete[] field;
    }
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
#define MAXN 500005
using namespace std;

int n,m,fa[MAXN];

int getfa(int Node){
	if(Node==fa[Node])return Node;
	else return fa[Node]=getfa(fa[Node]);
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)fa[i]=i;
	while(m--){
		int x,y;
		scanf("%d %d",&x,&y);
		fa[getfa(x)]=getfa(y);
	}
	int u=getfa(1),tot=0;
	for(int i=2;i<=n;++i)
	if(getfa(i)!=u)++tot,fa[getfa(i)]=u;
	printf("%d\n",tot);
	return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll a[100010];

map<ll, int> mp;

int main(void)
{
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll m = 0;
    REP(i, N) {
        for(int j = a[i] - 1; j <= a[i] + 1; j++){
            ll s = mp[j] + mp[j - 1] + mp[j + 1];
            m = max(s, m);
        }
    }
    cout << m << endl;

}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M, X = [int(x) for x in input().split()]
    C = []
    A = []
    for i in range(N):
        tmp = [int(x) for x in input().split()]
        C.append(tmp[0])
        A.append(tmp[1:])
    CA = [[C[i], v] for i, v in enumerate(A)]

    # TLE
    # l = list(itertools.permutations(CA, N))
    # anss = [100100100] * len(l)
    # for i, v in enumerate(l):
    #     arr = [0] * M
    #     s = 0
    #     for j in v:
    #         arr = python_list_add(arr, j[1])
    #         s += j[0]
    #         if all([x >= X for x in arr]):
    #             anss[i] = s
    #             break
    # ans = min(anss)
    # if ans == 100100100:
    #     print(-1)
    #     return
    # print(ans)

    # bit全探索
    anss = []
    for i in range(2 ** N):
        s = 0
        arr = [0] * M
        for j in range(N):
            if i >> j & 1:
                s += CA[j][0]
                arr = python_list_add(arr, CA[j][1])
            if all([x >= X for x in arr]):
                anss.append(s)
    print(min(anss) if anss else -1)

    return


def python_list_add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]


if __name__ == '__main__':
    main()


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int swap(int a, int b) {
}
int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int main() {

    int n;
    int a[MAXN];
    int r[MAXN], l[MAXN];
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

    l[0] = 0; r[n] = 0;

    for(int i=1; i<n; i++) {
        l[i] = gcd(l[i-1], a[i-1]);
    }

    for(int i=n-1; i>=0; i--) {
        r[i] = gcd(r[i+1], a[i]);
    }

    int g[MAXN];
    int ans =0;
    for(int i=0; i<n; i++) {
        g[i] = gcd(l[i], r[i+1]);
        ans = max(ans, g[i]);
    }

    cout << ans << endl;

}



Measured memory_bytes: 1408
N = int(input())
D = dict()
M = 0
for _ in range(N):
    s = input()
    if D.get(s) is None:
        D[s] = 1
    else:
        D[s] += 1
    M = max(M, D[s])
keys = sorted([k for k, n in D.items() if n == M])
for k in keys:
    print(k)
    

Measured memory_bytes: 33048
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
long long GCD(long long a,long long b){
    if(b==0)return a;
    return GCD(b,a%b);
}
long long LCM(long long a,long long b){
    return a*b/GCD(a,b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x;
    cin>>x;
    cout<<LCM(x,360)/x<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main()
{
 int i,c,k,n;
  c=0;
 cin >> n >> k;
 int a[n];
  for(i=0;i<n;i++)
  {
   cin >> a[i];
   if(a[i]>=k)
   c++;
  }
 cout << c;
 return 0;
}  

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}


Measured memory_bytes: 3284
H ,K = input().split(" ")
H = int(H)
K = int(K)


lst = input().split(" ")
hps = []
for l in lst:
  hps.append(int(l))

hps.sort(reverse=True)

if len(hps) < K:
  hps = [0]
else:
  hps = hps[K:]

sum_hps = sum(hps)
print(sum_hps)

Measured memory_bytes: 27560
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		int[] array = new int[10];
		Scanner stdIn = new Scanner(System.in);

		for(int i=0;i<10;i++){
			array[i] = stdIn.nextInt();
		}

		array = arraySort(array);
		System.out.println(array[0]+"\n"+array[1]+"\n"+array[2]);
	}

	//配列を降順にソート
	public static int[] arraySort(int[] array){

		// 最後の要素を除いて、すべての要素を並べ替えます
	    for(int i=0;i<array.length-1;i++){

	    	// 下から上に順番に比較します
	    	for(int j=array.length-1;j>i;j--){

	    		// 上の方が大きいときは互いに入れ替えます
	    		if(array[j]>array[j-1]){
	    			int t=array[j];
	    			array[j]=array[j-1];
	    			array[j-1]=t;
	    		}
	    	}
	    }
		return array;
	}
}

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

using namespace std;

int N;
int a[100];

void solve() {
    int Alice = 0;
    int Bob = 0;
    sort(a, a + N, greater<int>());
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    printf("%d\n", Alice - Bob);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	for {
		if a+1 < b {
			a++
		} else if a-1 >= 1 {
			a--
		}
		if b-1 > a {
			b--
		} else if b+1 <= n {
			b++
		}

		if a == 1 {
			fmt.Println("Borys")
			return
		}
		if b == n {
			fmt.Println("Alice")
			return
		}
	}
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int L = 0;
        int L_max = 0;
        for(int i = 0; i < n; i ++) {
            int l = sc.nextInt();
            L += l;
            L_max = Math.max(L_max, l);
        }
        if(L_max < L - L_max) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int wa = accumulate(A.begin(),A.end(),0);
    int sikii = wa/(4*M);
    if(wa%(4*M)!=0){
        sikii++;
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        if(A.at(i)>=sikii){
            cnt++;
        }
        else{
            break;
        }
    }
    if(cnt<M){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

string s_d, s_d_const, t;
string ans = "UNRESTORABLE";
int main() {
    cin >> s_d_const >> t;
    int s_size = s_d_const.size(), t_size = t.size(); 
    for (int i=0;i<s_size-t_size+1;i++) {
        s_d = s_d_const;
        for (int j=0;j<t_size; j++) {
            string s_sub = s_d.substr(i,t_size);
            if (s_sub[j] != t[j] && s_sub[j] != '?') break;
            else if (j==t_size-1) {
                s_d.replace(i,t_size,t);
                for (int k=0;k<s_d.size();k++) {
                    if(s_d[k]=='?') {
                        s_d.replace(k,1,"a");
                    }
                }
                if(ans=="UNRESTORABLE") ans = s_d;
                ans = min(s_d, ans);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int left;
int right;
int mid;

int main(){
  int n,q;
  int i,j;
  int count=0;
  
  scanf("%d",&n);
  int S[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];

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

  for(i=0;i<q;i++){
      left = 0;
      right = n;
      while(left<right){
	mid=(left + right)/2;
	if(T[i]==S[mid]){
	  count++;
	  break;
	}
	if(T[i]>S[mid]){
	  left = mid + 1;
	}
	else if(T[i]<S[mid]){
	  right = mid;
	}
      }
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2292
#include <stdio.h>
 
int main(void) {
	int N;
	int syougen[16][16] = {{0}};
	int i, j;
	int answer = 0;
	int search;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		for (j = 0; j < A; j++) {
			int x, y;
			if (scanf("%d%d", &x, &y) != 2) return 1;
			syougen[i][x - 1] = (y == 1 ? 1 : -1);
		}
	}
	for (search = 0; search < (1 << N); search++) {
		int score = 0;
		int ok = 1;
		for (i = 0; ok && i < N; i++) {
			if ((search >> i) & 1) {
				score++;
				for (j = 0; ok && j < N; j++) {
					if (syougen[i][j] != 0) {
						if (((search >> j) & 1) != (syougen[i][j] == 1)) ok = 0;
					}
				}
			}
		}
		if (ok && score > answer) answer = score;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void Partition() {
	int N;
	cin >> N;
	i64 M;
	cin >> M;
	//int rem = M % N;
	//if (rem == 0) {
	//	cout << (M / N) << "\n";
	//	return;
	//}
	int mo = M / N;
	//if (mo == 1) {
	//	cout << (mo) << "\n";
	//	return;
	//}
	//int res = rem;
	//int bm = mo;
	while (mo > 0)
	{
		if (M % mo == 0) {
			cout << mo << "\n";
			return;
		}
		mo--;
	}
}
 int main() {
	 Partition();
	 return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

flag = False

for i in range(100):
    for j in range(100):
        if flag == True:
            continue
        #print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;



int main(){
  ll n; ll k;
  cin>>n>>k;
  vector<ll> a(n);
  ll maxa=1;
  rep(i,n){
    cin>>a[i];
    if(maxa<a[i]) maxa=a[i];
  }

  if(k==0){
    cout<<maxa<<endl;
    return 0;
  }
  ll count=0;

  ll imin=1;
  bool ok=true;
  //cout<<"imin:"<<imin<<" "<<maxa<<endl;
  ll imax=maxa;
  ll now=(imax+imin)/2;
  ll count_plus=0;
  //cout<<"i:"<<imin<<" "<<imax<<endl;
  while(imax-imin>1){
    now=(imin+imax)/2;
    //cout<<"i:"<<imin<<" "<<imax<<endl;
    count=0;
    ok=true;
    rep(i,n){
      count_plus=a[i]/now;
      if(a[i]%now==0) count_plus=a[i]/now-1;
      if(k<count_plus || count>k-count_plus){// 刻み回数が多すぎる
        ok=false;
        break;
      }
      count+=count_plus;
    }

    if(ok){// now>=ans;
      imax=now;
    }else{// now<ans;
      imin=now;
    }
  }
  count=0;
  // imax-imin<=1;

  rep(i,n){
    count_plus=a[i]/imin;
    if(a[i]%imin==0) count_plus=a[i]/imin-1;
    if(k<count_plus || count>k-count_plus){// iminだと刻み回数が多すぎる
      cout<<imax<<endl;
      return 0;
    }

    count+=count_plus;

  }
  //iminでカット可能．
  cout<<imin<<endl;




}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int m, d;
	cin>>m>>d;
	int c = 0;
	// for(int i = 0)
	// vector<ll> a(n);
	for(int i = 10; i <= d; ++i)
	{
		// cin>>a[i];
		if(i%10>=2)
		{
			int temp = i/10;
			if(temp%10>=2)
			{
				for(int j = 1; j <= m; j++)
				{
					if((temp%10)*(i%10)==j)
					{
						c++;
					}
				}
			}
			else
			{
				;
			}
		}
		else
		{
			;
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])


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

int main(){
  int K,S,cnt = 0;
  cin >> K >> S;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= S - x && y <= K; y++){
        if( S - (x + y) <= K ) cnt++;
    }
  }
  cout << cnt << endl;
}


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 all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n, k; cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];

    vll b(n, 0);
    b[0] = 1;

    ll pos = 0;
    ll nxt;
    bool flg = false;
    rep(i, k){
        nxt = a[pos]-1;
        if(b[nxt]){
            flg = true;
            break;
        }
        b[nxt] = b[pos] + 1;
        pos = nxt;
    }
    //cout << b[nxt]-1 << endl; //ループの始点までの移動回数
    //cout << b[pos]+1-b[nxt] << endl; //ループの長さ

    if(flg){
        ll num = (k - (b[nxt]-1))%(b[pos]+1-b[nxt]);

        //cout << nxt << endl;
        rep(i, num){
            nxt = a[nxt]-1;
        }

        cout << nxt+1 << endl;
    }
    else{
        nxt = 0;
        rep(i, k){
            nxt = a[nxt]-1;
        }

        cout << nxt+1 << endl;
    }


    return 0;
}

Measured memory_bytes: 6412
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

int n, x, d;

void init() {
    scanf(III,&n,&x,&d); 
}

int cal(int a,int b) {
	return (a+a+b-1) * b/2;
}

void solve() {
    // index of i as the number of the integers player A choose
    // get a set of { x * (n-i*2) + d*... -> *... }
    // while sets may union, first x,d /= gcd(x,d)
    // it can be proved that this action will not influence the final answer ( for originally all the result got can be written as (k*gcd(...)) )
    // for (n-2*i) s \in {k*d+b} , calc the limits, then the size of
    if(d==0) { printf(IN,x?n+1:1); return ; }
    int g = __gcd(x, d);
    x /= g; d /= g;
    if (d < 0) { x = -x; d = -d; }
    int ans = 0;
    rep (i,d) {
        set < pr > s;
        for (int j=i;j<=n;j+=d) {
            s.insert( pr ( j/d*x+cal(0,j) , j/d*x+cal(n-j,j)+1 ) ); 
        } 
        int res = -1e18;
        for (auto it : s) {
		    ans += max(0LL,it.R - max(res,it.L));
            checkMax(res, it.R);
        }
    }
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
int main(void)
{
  int a[10000][2]={0};
  int i=0;
  int f;
  int temp;

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

  for (i=0; i<f; i++) {
	if (a[i][0]>a[i][1]) {
	  temp=a[i][0];
	  a[i][0]=a[i][1];
	  a[i][1]=temp;
	}
  }

  for (i=0; i<f; i++) {
	printf("%d %d\n",a[i][0],a[i][1]);
  }
  return 0;
}

Measured memory_bytes: 684
implicit none
integer (8):: a,b,c
character(1) :: s
read(*,*) s

if (s=="a" .or.  s=="i" .or.  s=="u" .or.  s=="e" .or.  s=="o" ) then
    write(*,*) "vowel"
else
    write(*,*) "consonant"    
endif
end


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

ll dp[3020][3020];
const ll MOD = 998244353LL;
int main() {
  int N, S; cin>>N>>S;
  vector<ll> two(1,1);
  for(int i = 0; i < N; i++) two.push_back(two.back() * 2LL % MOD);
  vector<int> A(N);
  REP(i,N) cin>>A[i];
  dp[0][0] = two[N];
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= S; j++) {
      dp[i+1][j] += dp[i][j];
      dp[i+1][j] %= MOD;
      const int u = j + A[i];
      if(u <= S) {
	ll v = dp[i][j];
	if(v % 2 == 0) v /= 2LL;
	else v = (v + MOD) / 2LL;
	dp[i+1][u] += v;
	dp[i+1][u] %= MOD;
      }
    }
    //    REP(j,S+1)
    //      cout << "(" << j << "," << dp[i+1][j] << ")";
    //    cout << endl;
  }
  cout << dp[N][S] << endl;
  return 0;
}


Measured memory_bytes: 74016
#include <bits/stdc++.h>
using namespace std;
#define MAX_INT 10000
#define PII pair<int, int>
#define VPII vector<PII >

int solve(int n, const vector<VPII >& adjacent) {
  vector<bool> used(n, false);
  int result = 0;
  priority_queue<PII, VPII, greater<PII > > q;
  for (auto v : adjacent[0]) q.push(v);
  used[0] = true;
  while(q.size() > 0) {
    PII current = q.top(); q.pop();
    if (!used[current.second]) {
      used[current.second] = true;
      result += current.first;
      for (auto v : adjacent[current.second]) q.push(v);
    }
  }

  return result;
}

int main() {
  int n, m;
  while (cin >> n >> m, n != 0) {
    vector<VPII > adjacent(n);
    for (int i = 0; i < m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      adjacent[a].push_back(make_pair(c, b));
      adjacent[b].push_back(make_pair(c, a));
    }
    cout << solve(n, adjacent) << endl;
  }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main() {
  int n;
  double ans=0,p[3005]={};
  cin >> n;
  for(int i=1; i<=n; i++) {
    cin >> p[i];
  }
  double dp[3005][3005]={};
  dp[0][0]=1;
  for(int i=1; i<=n; i++) {
    for(int j=0; j<=i; j++) {
      if(j>0) {
        dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
      }
      else {
        dp[i][j]=dp[i-1][j]*(1-p[i]);
      }
    }
  }
  for(int i=n/2+1; i<=n; i++) {
    ans+=dp[n][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;
        vector<ll> a(n);
        for(auto &e: a) cin >> e;
        sort(a.begin(), a.end());

        ll r = -1;
        for(ll i=0; i<n; i++) {
            ll j = upper_bound(a.begin(), a.end(), m-a[i]) - a.begin() - 1;
            if(i == j) j--;
            if(j < 0) continue;
            r = max(r, a[i]+a[j]);
        }
        if(r == -1) cout << "NONE" << endl;
        else cout << r << endl;
    }
}



Measured memory_bytes: 3200
from sys import stdin
import numpy as np

N, L = [int(x) for x in stdin.readline().rstrip().split()]

maxL = L+N-1
sumL = (L+maxL)*N//2
if L*maxL<=0:
    print(sumL)
else:
    if L>0:
        print(sumL-L)
    else:
        print(sumL-maxL)


Measured memory_bytes: 21544
#include<stdio.h>
int main(void)
{
	int a,b,c;
	int count;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b && b==c){
    	count=1;
    }
	else if(a==b||b==c||a==c){
    	count=2;
    }
	else{
    	count=3;
    }
	printf("%d",count);
	return 0;
}

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

ll N, X[5];

void solve() {
  sort(X, X + 5);
  ll res = 4;
  res += (N + X[0] - 1) / X[0];
  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> X[0] >> X[1] >> X[2] >> X[3] >> X[4];
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int N;cin>>N;
  
  vector<char> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(vec[i]=='A'&&vec[i+1]=='B'&&vec[i+2]=='C'){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256