akhauriyash/Code-Regression huggingface dataset:
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n,k;
    string s;
    cin>>s;
    if(s=="SUN") cout<<'7'<<endl;
    else if(s=="MON") cout<<'6'<<endl;
    else if(s=="TUE") cout<<'5'<<endl;
    else if(s=="WED") cout<<'4'<<endl;
    else if(s=="THU") cout<<'3'<<endl;
    else if(s=="FRI") cout<<'2'<<endl;
    else if(s=="SAT") cout<<'1'<<endl;
}


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  int cnt[200010] = {};
  REP(i,m) {
    int a,b;
    cin >> a >> b;
    if (a == 1) cnt[b]++;
    if (b == n) cnt[a]++;
  }
  bool f = 0;
  REP(i,n) {
    if (cnt[i] == 2) f = 1;
  }
  cout << (f?"POSSIBLE":"IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


const ll MAXN=100001;
ll par[MAXN];
ll rnk[MAXN];
ll Size[MAXN];

void shoki(){
    for(ll i=0;i<MAXN;i++) {par[i]=i; rnk[i]=0; Size[i]=1;}
}

ll sch(ll x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

ll con(ll A,ll B){
    A=sch(A);
    B=sch(B);
    if(A==B) return 0;
    if(rnk[A]>rnk[B]) swap(A,B);
    ll aa=Size[A], bb=Size[B];
    par[A]=B;
    Size[B]+=Size[A];
    Size[A]=Size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return aa*bb;
}

ll is_size(ll k){
    return Size[sch(k)];
}

bool same(ll A,ll B){
    return sch(A)==sch(B);
}

int main(){
    shoki();
    ll N,M; cin>>N>>M;
    vector<P> d;
    rep(i,M){
        ll a,b; cin>>a>>b;
        d.pb(mp(a,b));
    }
    vec ans(M+1, N*(N-1)/2);
    reverse(ALL(d));
    rep(i,M) ans[i+1]=ans[i]-con(d[i].first,d[i].second);
    reverse(ALL(ans));
    REP(i,1,M+1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 6000
n = int(input())
listForList = []

index = 0
while index < n:
    listI = list(input())
    listI.sort()
    listForList.append(listI)
    index += 1

if len(listForList) == 1:
    print("".join(listForList[0]))
else:
    index2 = 0
    pendingL = []
    while index2 < len(listForList)-1:
        if index2 == 0:
            for c in listForList[index2]:
                if c in listForList[index2+1]:
                    pendingL.append(c)
        else:
            newPL = []
            for ch in pendingL:
                if ch in listForList[index2+1]:
                    newPL.append(ch)
                    listForList[index2+1].remove(ch)
            pendingL = newPL
            if pendingL == []:
                print("")
                break
        index2 += 1

    if index2 == len(listForList)-1:
        print("".join(pendingL))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
const int N=41;
int ma,mb,n,a[N],b[N],c[N];
int dp[N][401][401],ans;

int main(){
	cin>>n>>ma>>mb;
	FOR(i,0,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	fill(dp[0][0],dp[N][0],inf);
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		FOR(ca,0,40*10){
			FOR(cb,0,40*10){
				if(dp[i][ca][cb]==inf)continue;
				dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
			}
		}
	}
	ans=inf;
	FOR(ca,1,40*10+1){
		FOR(cb,1,40*10+1){
			if(ca*mb==cb*ma)ans=min(ans,dp[n][ca][cb]);
		}
	}
	if(ans==inf)ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n;
	cin >> n;
	long prev=0;
	int cnt=0;
	int max_cnt=0;
	for(int i=0; i<n; i++){
		long cur;
		cin >> cur;
		if(i==0){
			prev=cur;
		}else{
			if(cur>prev){
				max_cnt = max(max_cnt, cnt);
				cnt=0;
			}else{
				cnt++;
			}
			prev=cur;
		}
		max_cnt = max(max_cnt, cnt);
	}
	cout << max_cnt << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int n,c;
    scanf("%d",&n);
    int h[n];
    for(int i=0; i<n; i++){
        scanf("%d",&h[i]);
    }
    c=0;
    for(int i=n-1;i>0;i-=1){
        if(h[i]-h[i-1]>=0){
            c++;
        }
        else if(h[i]-h[i-1]<0){
            h[i-1]-=1;
            if(h[i]-h[i-1]>=0){
                c++;
            }
        }
    }
    if(c==n-1){
        printf("Yes\n");
    }
    else{
       printf("No\n");

    }
    return 0;
}

Measured memory_bytes: 640
<?php
  list($n, $k) = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $loop = min($k, 50);
  for ($h=0; $h<$loop; $h++) {
    $x = array_fill(0, $n+1, 0);
    for ($i=0; $i<$n; $i++) {
      $l = max($i-$a[$i], 0);
      $r = min($i+$a[$i]+1, $n);
      $x[$l]++;
      $x[$r]--;
    }
    $a[0]=$x[0];
    for ($i=1; $i<$n; $i++) {
      $a[$i]=$a[$i-1]+$x[$i];
    }
  }

  echo implode(" ", $a);

Measured memory_bytes: 42212
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N; cin>>N;
    int a = N/1000, b = (N%1000)/100, c = (N%100)/10, d = N%10;
    cout << (((a==b&&b==c)||(b==c&&c==d)) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
ss=set(s)

if len(ss)==2 and ((s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2])):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n; cin >> n;
    vector<ll> l(n+1);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++)
    {
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<vector<int>> a(n, vector<int>(n-1));
	for (auto &i: a) for (auto &j: i) { scanf("%d", &j); j--; }
	vector<int> outdeg(n*n+5, 0);
	vector<vector<int>> adj(n*n+5);
	vector<int> indeg(n*n+5, 0);
	vector<vector<int>> cadj(n*n+5);
	for (int i=0; i<n; i++) {
		for (int j=0; j<n-1; j++) {
			// for (int k=j+1; k<n-1; k++) {
				int k = j+1;
				if (k>=(n-1)) continue;
				int l1 = min(i, a[i][j]), l2 = max(i, a[i][j]);
				int p1 = min(i, a[i][k]), p2 = max(i, a[i][k]);
				adj[l1*n+l2].push_back(p1*n+p2);
				cadj[p1*n+p2].push_back(l1*n+l2);
				indeg[p1*n+p2]++;
				outdeg[l1*n+l2]++;
			// }
		}
	}

	// int ind = -1;
	queue<int> q;
	for (int i=0; i<(n*n); i++) {
		int sec = i%n, fir = i/n;
		if (fir>=sec) continue;
		if (indeg[i]==0) {
			q.push(i);
		}
	}

	int vis = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		vis++;
		for (int v: adj[u]) {
			indeg[v]--;
			if (indeg[v]==0) q.push(v);
		}
	}

	if (vis!=(n*(n-1)/2)) {
		printf("-1\n");
		return 0;
	}

	vector<int> d(n*n+5, 0);

	for (int i=0; i<(n*n); i++) {
		int sec = i%n, fir = i/n;
		if (fir>=sec) continue;
		if (outdeg[i]==0) {
			d[i] = 1;
			q.push(i);
		}
	}

	int cnt = 0;

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		cnt++;
		for (int v: cadj[u]) {
			outdeg[v]--;
			d[v] = max(d[v], d[u]+1);
			if (outdeg[v]==0) q.push(v);
		}
	}
	// cerr << "cnt = " << cnt << endl;
	printf("%d\n", *max_element(d.begin(), d.end()));
}

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

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 1e13
#define ll long long
const ll mod = 2333;
const int N = 1e5 + 10;
const int M = 2e6 + 1005;
using namespace std;
map<pii,int> hap;
struct Edge
{
    int next;
    int to;
}edge[N*2];
int deg[N];
int head[N],tot;
inline void add(int from,int to){
    edge[++tot].next= head[from];
    edge[tot].to = to;
    head[from] = tot;
    deg[to] ++;
}
inline void init(){
    mmt(head,-1);
    tot = 0;
}
void dfs(int root,int fa,int color,int color_num){
    for(int i = head[root];~i;i = edge[i].next){
        int y = edge[i].to;
        if(y != fa){
           // cout<<"y: "<<y<< " "<<" c  "<<color<<endl;
            hap[{root,y}] = hap[{y,root}] = color;
            color = (++color)%color_num;
            dfs(y,root,color,color_num);
        }
    }
   // cout<<"UES"<<endl;
}
pii res[N];
int main()
{
    init();
    int n;
    read(n);

    int u,v;
    for(int i = 1;i <= n - 1;++i){
        scanf("%d%d",&u,&v);//重边？
        add(u,v);
        add(v,u);
        res[i].first = u;res[i].second = v;
    }
    int root;
    int MAX = -1;
    for(int i = 1;i <= n;++i){
        if(MAX < deg[i]){
           MAX = deg[i];
           root = i;
        }
    }
    cout<<MAX<<endl;
    //cout<<root;
   // return 0;
    dfs(root,-1,0,MAX);
    for(int i = 1;i <= n - 1;++i){
        cout<<hap[res[i]] +1<<endl;
    }
}


Measured memory_bytes: 18688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int r;

int main(){
    cin >> r;
    cout << 3*r*r << endl;
    return 0;

}

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

int main() {
string S;
cin>>S;
if(S.at(0)=='R'){
    if(S.at(1)=='R'){
        if(S.at(2)=='R'){
            cout<<'3'<<endl;
        }else{
            cout<<'2'<<endl;
            return 0;
        }
    }else if(S.at(2)=='R'){
        cout<<'1'<<endl;
    }else{
        cout<<'1'<<endl;
    }
}else if(S.at(1)=='R'){
    if(S.at(2)=='R'){
        cout<<'2'<<endl;
    }else{
        cout<<'1'<<endl;
    }
}else if(S.at(2)=='R'){
cout<<'1'<<endl;
}else{
    cout<<'0'<<endl;
}
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String ard[]) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();

        int max;
        max = A * 10 + B + C;
        if (max < A + B * 10 + C) {
            max = A + B * 10 + C;
        }
        if (max < A + B + C * 10) {
            max = A + B + C * 10;
        }

        System.out.println(max);

        scan.close();
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second                   
#define fori(i, a, b, c) 	for (int i = (int)(a); i <= (int)(b); i += (int)(c))
#define ford(i, a, b, c) 	for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define MOD 998244353

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lol;
typedef vector<lol> vlol;

ifstream in ("input");

const int NR = 2e5 + 5;

lol a[NR], ap[NR], n, sol;
bool used[NR];

int main()	{
	ios::sync_with_stdio(false);
	int i;
	cin >> n;
	fori(i, 1, n, 1)	{
	 	cin >> a[i];
		ap [a[i]]++;
	}	 
	fori(i, 1, n, 1)
		if (!used[a[i]])
		sol += ap[a[i]]*(ap[a[i]]-1)/2, used[a[i]] = 1;
	fori(i, 1, n, 1)	
		cout << sol - ap[a[i]]*(ap[a[i]]-1)/2 + (ap[a[i]]-2)*(ap[a[i]]-1)/2 << '\n';

}












Measured memory_bytes: 4992
from sys import stdin

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())

k = I()
s = S()

if len(s)<=k:
    print(s)
else:
    a = ''
    for i in range(k):
        a += s[i]
    a += '...'
    print(a)

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

if n % 2 == 1:
    print(0)
else:
    n2 = 0
    n5 = 0
    i = 2
    while i <= n:
        n2 += n//i
        i *= 2
    i = 10
    while i <= n:
        n5 += n//i
        i *= 5
    # print(n2,n5)
    print(min(n2,n5))

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int main(){
	//freopen("in.txt","r",stdin);
	int n=read(),r=read();
	int ans=0;
	if(n>=10)
		ans=r;
	else ans=r+100*(10-n);
	printf("%d\n",ans);
	return 0;
}





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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int sx,sy;
  char ba[w][h];
  REP(y,h) REP(x,w) {
    cin >> ba[x][y];
    if (ba[x][y] == 'S') {
      sx = x;
      sy = y;
    }
  }
  typedef pair<int,int> pii;
  int dx[] = {0,1,0,-1};
  int dy[] = {1,0,-1,0};
  int res = 0;
  REP(i,n) {
    queue<pii> Q;
    Q.push(pii(sx,sy));
    int dis[w][h];
    memset(dis,-1,sizeof(dis));
    dis[sx][sy] = 0;
    while(Q.size()) {
      int x = Q.front().first;
      int y = Q.front().second;
      Q.pop();
      if (ba[x][y] == '0' + i + 1) {
        res += dis[x][y];
        sx = x;
        sy = y;
        break;
      }
      REP(k,4) {
        int xx = x + dx[k];
        int yy = y + dy[k];
        if (xx<0 || w<=xx || yy<0 || h<=yy) continue;
        if (ba[xx][yy] == 'X') continue;
        if (dis[xx][yy] != -1) continue;
        dis[xx][yy] = dis[x][y] + 1;
        Q.push(pii(xx,yy));
      }
    }
  }
      cout << res << endl;
}

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

int main(){
    string s;
    cin >> s;

    int cnt[26] = {};
    for(int i = 0; i < s.length(); i++){
        cnt[s[i]-'a']++;
        if(cnt[s[i]-'a'] == 2)  cnt[s[i]-'a'] = 0;
    }

    int alone = 0;
    for(int i = 0; i < 26; i++) alone += cnt[i];

    cout << alone/2 << endl;

    return 0;
}


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


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Slist();

            var sum = Ai.Sum();
            var max = Ai.Max();
            if (0 == max)
            {
                WriteLine(0);
                return;
            }
            var dc = yaku(sum).OrderByDescending(e => e.Key);
            foreach (var pk in dc)
            {
                Ai.Sort((l, r) => (int)(r % pk.Key - l % pk.Key));
                var b = 0;
                var e = (int)N - 1;
                var ln = Ai[b] % pk.Key;
                var rn = Ai[e] % pk.Key;
                var ope = 0L;
                while (b < e)
                {
                    if (K < ope)
                        break;
                    if (pk.Key == ln + rn)
                    {
                        ope += rn;
                        ln = Ai[++b] % pk.Key;
                        rn = Ai[--e] % pk.Key; ;
                        if (e <= b)
                        {
                            if (ope <= K)
                            {
                                WriteLine(pk.Key);
                                return;
                            }
                        }
                    }
                    else if (pk.Key < ln + rn)
                    {
                        ope += pk.Key - ln;
                        rn = ln + rn - pk.Key;
                        ln = Ai[++b] % pk.Key;
                    }
                    else
                    {
                        ope += rn;
                        ln += rn;
                        rn = Ai[--e] % pk.Key;
                    }
                }
            }
            WriteLine(1);
        }
        static Dictionary<long, long> yaku(long n)
        {
            var ret = new Dictionary<long, long>();
            for (long i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    ret[i] = 1;
                    ret[n / i] = 1;
                }
            }
            return ret;
        }
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    vector<i64> C(N + 1, 0);
    REP(i, N) C[i + 1] = C[i] + A[i];

    i64 cnt = 0;
    unordered_map<i64, i64> dist;
    auto left = [&](i64 l) {
        return (C[l] - l + 1) % K;
    };
    auto right = [&](i64 r) {
        return (C[r + 1] - r) % K;
    };
    REP(r, N) {
        dist[left(r)]++;
        if (r - K + 1 >= 0) dist[left(r - K + 1)]--;
        cnt += dist[right(r)];
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 11592
import sys
readline = sys.stdin.readline

def solve():
    N, D = map(int, readline().split())
    
    count = 0
    for i in range(N):
        x,y = map(int, readline().split())
        if x**2 + y**2 <= D**2:
            count += 1
    
    print(count)

solve()

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

signed main(){
	int x1,x2,y1,y2, hen;
	int x3,x4,y3,y4;
	
	cin>>x1>>y1>>x2>>y2;
	
	
	hen = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
	//cout<<hen<<endl;
	
	for(int i = -400; i <=400; i++){
		int f = 0;
		for(int j = -400; j <= 400; j++){
			if((x1-x2)*(i-x2)+(y1-y2)*(j-y2) == 0 && (i-x2)*(i-x2) + (j-y2)*(j-y2) == hen){
				x3 = i;
				y3 = j;
				
				//if(x3+(x1-x2) == x1+(x3-x2) && y3 + (y1-y2) == y1 + (y3-y2))break;
				//cout<<i<<" "<<j<<endl;
				
				if(x1==x2){
					if(y2>y1 && x3 < x1){
						f = 1;
						break;
					}if(y2<y1 && x3 > x1){
						f = 1;
						break;
					}
				}
				else if(y1==y2){
					if(x2>x1&& y3 > y1){
						f = 1;
						break;
					}if(x2<x1 && y3 < y1){
						f = 1;
						break;
					}
				}
				else {
					if(x2 > x1 && y3 > y2){
						f = 1;
						break;
					
					}
				
					if(x2 < x1 && y3 < y2){
						f = 1;
						break;
					
					}
				}
				
				
			
			}
		}
		if(f == 1) break;
	}
	
	cout<<x3<<" "<<y3<<" "<<x3+(x1-x2)<<" "<<y3+(y1-y2)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    if abs(K - x[i]) > abs(x[i]):
        ans += 2 * x[i]
    else:
        ans += 2 * (K - x[i])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
#define pb push_back
struct edge{int to,cost;};
typedef pair<int,int> P;
int n,m,r,d[111111];
vector<edge>v[111111];
void dijkstra(int x){
	fill(d,d+n,INF);
	d[x]=0;
	priority_queue<P,vector<P>,greater<P>>q;
	q.push({x,0});
	while(!q.empty()){
		P p=q.top();
		q.pop();
		for(edge e:v[p.first]){
			if(d[e.to]>p.second+e.cost){
				d[e.to]=p.second+e.cost;
				q.push({e.to,d[e.to]});
			}
		}
	}
}
signed main(){
	cin>>n>>m>>r;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		v[a].pb({b,c});
	}
	dijkstra(r);
	rep(i,n){
		if(d[i]==INF)puts("INF");
		else cout<<d[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 34128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
#include<limits>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n;
  while (cin >> n && n) {
    int a[n];
    int sum = 0;
    R(i,0,n) {
      cin >> a[i];
      sum += a[i];
    }
    sum /= n;
    int cnt = 0;
    R(i,0,n) {
      if (a[i] <= sum) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0) {
		cout << "delicious" << endl;
	} else if (b - a <= x) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    cand =[[0]]
    for i in range(1, l+1):
        cand.append([])
        for m in cand[i-1]:
            c = cand[i]
            c.append(m+3*(10**(i-1)))
            c.append(m+5*(10**(i-1)))
            c.append(m+7*(10**(i-1)))

    ret = 0
    for i in range(3, l+1):
        for j in cand[i]:
            set_ = set(str(j))
            if len(set_) < 3:
                continue
            if j <= n:
                ret += 1
    print(ret)

if __name__ == "__main__":
    s = input()
    n = int(s)
    l = len(s)
    main()

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using ldouble = long double;

void input(int& rnWide, int& rnHigh, int& rnx, int& rny)
{
  cin >> rnWide >> rnHigh >> rnx >> rny;
}

void calcRectCutArea(int nWide, int nHigh, int nx, int ny)
{
  llong nRectArea = (llong)nWide * nHigh;
  ldouble nRectCutArea = nRectArea / 2.0L;
  cout << nRectCutArea << " ";

  double nCenterx = nWide / 2.0;
  double nCentery = nHigh / 2.0;
  if (nCenterx == nx && nCentery == ny)
    cout << "1" << endl;
  else
    cout << "0" << endl;
}
  
int main()
{
  int nWide, nHigh, nx, ny;

  input(nWide, nHigh, nx, ny);
  calcRectCutArea(nWide, nHigh, nx, ny);

  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const int INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> s(n),p(n),q(n);
  for(int i=0;i<n;i++){
    s.at(i) = i+1;
    cin >> p.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> q.at(i);
  }
  int a = 0,b = 0,i = 0;
  do{
    i++;
    if(s == p)a = i;
    if(s == q)b = i;
  }
  while(next_permutation(s.begin(),s.end()));
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 3640
N = int(input())
#print(N)
K = int(input())
#print(K)
X = int(input())
#print(X)
Y = int(input())
#print(Y)

ans = 0
for i in range(N):
  if i+1 <= K:
    ans += X
  else:
    ans += Y
      
print(ans)

Measured memory_bytes: 62620
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,M;
vector<pair<int,int> > towns[100005];
pair<int,int> ans[100005];
signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,M){
        int p,y;
        scanf("%lld %lld",&p,&y);
        towns[p].pb(mp(y,i));
    }
    rep(i,N+1){
        sort(towns[i].begin(),towns[i].end());
        rep(j,towns[i].size()){
            ans[towns[i][j].second]= mp(i,j+1) ;
        }     
    }
    rep(i,M){
        printf("%06lld%06lld\n",ans[i].first,ans[i].second);
    }
    
}


Measured memory_bytes: 8576
from typing import List


def bublle_sort(A: List[int]) -> List[int]:
    cnt = 0
    flg = True
    while flg:
        flg = False
        for i in reversed(range(1, N)):
            if A[i] < A[i - 1]:
                A[i], A[i - 1] = A[i - 1], A[i]
                cnt += 1
                flg = True
    return A, cnt


N = int(input())
A = [int(i) for i in input().split()]
A, cnt = bublle_sort(A)
print(' '.join(map(str, A)))
print(cnt)



Measured memory_bytes: 7156
//============================================================================
// Name        : Test4.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,buffa,i;
	cin>>a>>b>>c;
	for(i=0;i<10;i++){
	if(a>b){
		buffa=a;
		a=b;
		b=buffa;
		}
	else if(a>c){
		buffa=a;
		a=c;
		c=buffa;
	}
	else if(b>c){
		buffa=b;
		b=c;
		c=buffa;
	}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;

}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define INF 10000000

using namespace std;
struct edge{int to,cost;};
deque<pair<int,int>> d; //頂点と使用したか否か
vector<edge> v[100010];
int used[100010],dist[100010];
int i,k;
void zero_one_bfs(int s){
	for(i=0;i<k;i++){
		dist[i] = INF;
		used[i]= 0;
	}
	dist[s] = 0;
	d.push_front(make_pair(s,used[s]));
	while(d.size()){
		pair<int,int> p = d.front();
		int x=p.first,y=p.second;
		d.pop_front();
		used[x] = 1;
		for(i=0;i<v[x].size();i++){
			if(used[v[x][i].to]){
				continue;
			}
			if(v[x][i].cost==0){
				d.push_front(make_pair(v[x][i].to,0));
				dist[v[x][i].to] = dist[x];
			}else{
				d.push_back(make_pair(v[x][i].to,0));
				dist[v[x][i].to] = dist[x]+1;
			}
		}
	}
}

int main(){
	cin >> k;
	for(i=0;i<k;i++){
		edge e;
		e.to = (i+1)%k;
		e.cost = 1;
		v[i].push_back(e);
		e.to = 10*i%k;
		e.cost = 0;
		v[i].push_back(e);
	}
	zero_one_bfs(1);
	cout << dist[0]+1 << endl;
}

Measured memory_bytes: 7040
// AOJ 2223: Kaeru Jump
// 2017.12.9

#include <stdio.h>
#include <string.h>

char m[12][12]; int h, w;
int tr['Z'];
char sd[4] = {'U','R','D','L'};
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char ans[100];
char buf[10], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int rec(int r, int c, int dir, int leaf, char *p)
{
	int d, r2, c2;

	if (leaf == 1) { *p = 0; return 1; }
	dir += 2; if (dir >= 4) dir -= 4;
	for (d = 0; d < 4; d++) {
		if (d == dir) continue;
		r2 = r, c2 = c;
		while (1) {
			r2 += mv[d][0], c2 += mv[d][1];
			if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w) break;
			if (m[r2][c2] == 'o') {
				*p = sd[d];
				m[r][c] = '.';
				if (rec(r2, c2, d, leaf-1, p+1)) return 1;
				m[r][c] = 'o';
				break;
			}
		}
	}
	return 0;
}

int main()
{
	int r, c, sr, sc, leaf, d;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;
	fgets(p=buf, 10, stdin), h = getint(), w = getint();
	leaf = 0;
	for (r = 0; r < h; r++) {
		fgets(m[r], 12, stdin);
		for (c = 0; c < w; c++) {
			if      (m[r][c] == '.');
			else if (m[r][c] == 'o') leaf++;
			else {
				d = tr[m[r][c]];
				sr = r, sc = c;
				m[r][c] = 'o', leaf++;
			}
		}
	}
	rec(sr, sc, d, leaf, ans);
	puts(ans);
	return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(m), b(m); rep(i, m)cin >> a[i] >> b[i];
	int tmp = 0; int tmp2 = INF;
	rep(i, m)chmax(tmp, a[i]);
	rep(i, m)chmin(tmp2, b[i]);
	cout << max(0LL, tmp2 - tmp + 1) << endl;
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// Longest Common Substring

ll dp[3030][3030];

// dp[i][j] := sのi文字目とtのj文字目までのLCSの長さ


int main() {
    string s, t;
    cin >> s >> t;

    // LCS文字列取得パート
    int n = s.size(), m = t.size();
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (i == 0 or j == 0) {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }

    // 復元パート
    string rewsna = "";
    while (n > 0 and m > 0) {
        if (dp[n][m] == dp[n-1][m]) n--;
        else if (dp[n][m] == dp[n][m-1]) m--;
        else {
            rewsna += s[n-1];
            n--;
            m--;
        }
    }

    reverse(rewsna.begin(), rewsna.end());
    cout << rewsna << endl;

}


Measured memory_bytes: 71936
#include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if((x >= r && x <= W-r) && (y >= r && y <= H-r))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}



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

using ll=long long;
const ll MOD=1e9+7;
ll powm(ll x,ll k){
    if(k<0) return 0;
    ll res=1;
    while(k){
        if(k&1) res*=x;
        res%=MOD;
        x*=x;
        x%=MOD;
        k>>=1;
    }
    return res;
}
int main(){
    string s;
    cin>>s;
    int yq=0;
    int yc=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?') yq++;
        if(s[i]=='C') yc++;
    }

    int a=0;
    int xq=0;
    ll res=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?') yq--,xq++;
        if(s[i]=='A') a++;
        if(s[i]=='C') yc--;
        if(s[i]=='B'){
            res+=((xq*powm(3,xq-1)%MOD+a*powm(3,xq)%MOD)%MOD*((yq*powm(3,yq-1)+yc*powm(3,yq))%MOD))%MOD;
            res%=MOD;
        }
        if(s[i]=='?'){
            xq--;
            res+=((xq*powm(3,xq-1)%MOD+a*powm(3,xq)%MOD)%MOD*((yq*powm(3,yq-1)+yc*powm(3,yq))%MOD))%MOD;            
            res%=MOD;
            xq++;
        }
        //cout<<res<<endl;
    }
    cout<<res<<endl;

    
    return 0;
}

Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      //長さ4の文字列
      String date = sc.nextLine();
      //後ろの二文字
      String str1 = date.substring(2);
      //前の二文字
      String str2 = date.substring(0,2);
      
      //後ろの二文字を数字化する
      int month = Integer.parseInt(str1);
      
      if(month >= 1 && month <= 12){
        //前の二文字を数字化する
        int month1 = Integer.parseInt(str2);
        if(month1 >= 1 && month1 <= 12){
          System.out.print("AMBIGUOUS");
        }else{
          System.out.print("YYMM");
        }
      }else{
          int month1 = Integer.parseInt(str2);
          if(month1 >= 1 && month1 <= 12){
            System.out.print("MMYY");
          }else{
            System.out.print("NA");
          }
      }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, k, a[200001], b[200001], t;

int main(int argc, char **argv) {
	cin >> n >> m >> k;
	a[0] = 0;
	REP(i, n) {
		cin >> t;
		a[i+1] = a[i] + t;
	}
	REP(i, m) {
		cin >> t;
		b[i+1] = b[i] + t;
	}
	ll res = 0;
	REP(i, n+1) {
		if (a[i] > k) break;
		t = k - a[i];
		ll l = 0, r = m+1;
		while (l + 1 < r) {
			ll m = (l + r) / 2;
			if (b[m] <= t) l = m;
			else r = m;
		}
		res = max(res, i+l);
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;
#define mx 100005

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll x,i;
    cin >> x;
    bool vis[mx];
    memset(vis,0,sizeof(vis));
    for(i=2;i<=mx;i++)
    {
        if(vis[i]) continue;
        if(i>=x) break;
        for(ll j=i;j<=mx;j+=i) vis[j]=1;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3744
n,m = map(int,input().split())
H = list(map(int,input().split()))
l = [0]*n
AB = [list(map(int,input().split())) for _ in range(m)]
for a,b in AB:
    if H[a-1]>H[b-1]:
        l[a-1] += 1
        l[b-1] -= 10000
    elif H[a-1]==H[b-1]:
        l[a-1] -= 10000
        l[b-1] -= 10000
    else:
        l[a-1] -= 10000
        l[b-1] += 1
ans = 0
for _ in range(n):
    if l[_]>=0:
        ans += 1
print(ans)

Measured memory_bytes: 93624
using System;
using System.Linq;

class prog{
  static void Main(){
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int w = input[0];
    int a = input[1];
    int b = input[2];
    int ans = 0;
    if(a > b + w||b > a + w) ans = Math.Abs(a - b) - w;
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13396
n = int(input())
A = list(map(int, input().split()))

i = 0
flag = True # T: decreasing, F:increasing
num_stock = 0
money = 1000
while i < n:
    # 下がるところまで下げる
    if flag:
        while i + 1 < n and A[i] >= A[i + 1]:
            i += 1
        # 最後まで下がり続けた場合
        if i == n - 1:
            break
        num_stock = money // A[i]
        money -= num_stock * A[i]
        flag = False
    # 上がるとこまで上げる
    else:
        while i + 1 < n and A[i] <= A[i + 1]:
            i += 1
        money += num_stock * A[i]
        num_stock = 0
        flag = True
    i += 1

print(money)

Measured memory_bytes: 61724
def resolve():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print("1")
    elif H%2 == 1 and W%2 == 1:
        print((H-1)*(W-1)//2+(H-1)//2+(W-1)//2+1)
    elif H%2 == 1 and W%2 == 0:
        print((H-1)*W//2+W//2)
    elif H%2 == 0 and W%2 == 1:
        print(H*(W-1)//2+H//2)
    else:
        print(H*W//2)
resolve()

Measured memory_bytes: 3064
#include <stdio.h>
   
   int main(void) {
       int sum1, sum2, sum3;
       int a, b, c;
     
       scanf("%d %d %d" , &a, &b, &c);

       sum1 = a + b;
       sum2 = b + c;
       sum3 = c + a;

       if(sum1 < sum2 && sum1 < sum3) {
          printf("%d\n",sum1);
       }else if(sum2 < sum1 && sum2 < sum3){
          printf("%d\n",sum2);
       }else if(sum3 < sum1 && sum3 < sum2){
          printf("%d\n",sum3);
       }else if(sum1 == sum2 && sum2 == sum3){
          printf("%d\n",sum1);
       }
   return 0;
}

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

int main() {

    int n;

    cin >> n;

    int a,b,c,d;

    d = n%10;
    n /= 10;
    c = n%10;
    n /= 10;
    b = n%10;
    n /= 10;
    a = n%10;
    char op[3];

    if(a+b+c+d == 7){
        op[0] = '+';
        op[1] = '+';
        op[2] = '+';
    }
    else if(a+b+c-d == 7){
        op[0] = '+';
        op[1] = '+';
        op[2] = '-';
    }
    else if(a+b-c+d == 7){
        op[0] = '+';
        op[1] = '-';
        op[2] = '+';
    }
    else if(a+b-c-d == 7){
        op[0] = '+';
        op[1] = '-';
        op[2] = '-';
    }
    else if(a-b+c+d == 7){
        op[0] = '-';
        op[1] = '+';
        op[2] = '+';
    }
    else if(a-b+c-d == 7){
        op[0] = '-';
        op[1] = '+';
        op[2] = '-';
    }
    else if(a-b-c+d == 7){
        op[0] = '-';
        op[1] = '-';
        op[2] = '+';
    }
    else if(a-b-c-d == 7){
        op[0] = '-';
        op[1] = '-';
        op[2] = '-';
    }

    cout << a << op[0] << b << op[1] << c << op[2] << d << "=7" << endl;

    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;cin>>x;
	for(int i=0;i<=300;i++){
		for(int j=-300;j<=i;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){cout<<i<<" "<<j<<'\n';return 0;}
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int d = 0;
		for (int j = 1; j <= i; ++j)
		{
			if (i%j == 0)++d;
		}
		if (d == 8)++cnt;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
    using namespace std;
    main(){
      int n;cin >> n;
      int t[100010],x[100010],y[100010];
      t[0]=x[0]=y[0]=0;
      for(int i=0;i<n;i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
      string ans="Yes";
      for(int i=0;i<n;i++){
        int dt = t[i+1]-t[i];
        int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(dt>=dist){
          if(dt%2!=dist%2) ans="No";
        } else {
          ans = "No";
        }
      }
      cout << ans <<endl;
      return 0;
    }

Measured memory_bytes: 4756
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

template <typename T>
int binary_search(std::vector<T>& seq, T key)
{
    auto is_ok = [&](int index) { return seq[index] >= key; };
    int ng = -1;
    int ok = seq.size();

    while (std::abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (is_ok(mid))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

ll dist(ll x, vl& s, vl& t, int offset1, int offset2) {
    ll dist = 0LL;
    int idx1 = binary_search(s, x);
    idx1 += offset1;
    ll first = s[idx1];
        if (idx1 >= s.size()) return 1e12;
    dist += abs(x - first);
    int idx2 = binary_search(t, first);
    idx2 += offset2;
        if (idx2 >= t.size()) return 1e12;
    dist += abs(t[idx2] - first);
    return dist;        
}

int main()
{
    ios::sync_with_stdio(false);

    ll A, B, Q;
    cin >> A >> B >> Q;
    vl s(A); REP(i, A) cin >> s[i];
    vl t(B); REP(i, B) cin >> t[i];

    REP(i, Q) {
        ll x;
        cin >> x;
        ll ans = 1e12;
        ans = min(ans, dist(x, s, t, 0, 0));
        ans = min(ans, dist(x, s, t, 0, -1));
        ans = min(ans, dist(x, s, t, -1, 0));
        ans = min(ans, dist(x, s, t, -1, -1));
        ans = min(ans, dist(x, t, s, 0, 0));
        ans = min(ans, dist(x, t, s, 0, -1));
        ans = min(ans, dist(x, t, s, -1, 0));
        ans = min(ans, dist(x, t, s, -1, -1));

        cout << ans << endl;
    }



    return 0;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;

char X, Y;

int main() {
  cin >> X >> Y;

  if (X > Y)
    cout << ">" << endl;
  else if (X < Y)
    cout << "<" << endl;
  else
    cout << "=" << endl;

  return 0;
}


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

int GCD(int a, int b) {
	if (b == 0) return a;
	return GCD(b, a % b);
}

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	printf(C % GCD(A, B) == 0 ? "YES\n" : "NO\n");
	return 0;
}


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

#define ll long long

int main(){
 long int n,i,k;
  cin>>k;
  string s;
  cin>>s;
  n=s.length();
  if(n<=k){ cout<<s<<endl;}
	else {
      for(i=0;i<k;i++){ cout<<s[i]; }
      cout<<"..."<<endl;
    }
return 0;	
}


Measured memory_bytes: 3628