akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (1010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,A,B,a[N][N];
int main(){
	read(n),read(m),read(A),read(B);
	if(A>m/2||B>n/2)puts("-1"),exit(0);
	for(int i=1;i<=B;i++)
	for(int j=1;j<=A;j++)a[i][j]=1;
	for(int i=B+1;i<=n;i++)
	for(int j=A+1;j<=m;j++)a[i][j]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
		printf("%d",a[i][j]); puts("");
	}
	
}

Measured memory_bytes: 7296
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    xx = MII()
    print(xx.index(0)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define MOD 1000000007

int main(){
  long long n,m;
  cin >> n >> m;
  long long s[n+1],t[m+1];
  for(int i=1;i<n+1;i++){
    cin >> s[i];
  }
  for(int i=1;i<m+1;i++){
    cin >> t[i];
  }
  long long sum[n+1][m+1];
  long long dp[n+1][m+1];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<m+1;j++){
      sum[i][j] = 0;
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 0;

  for(int i=1;i<n+1;i++){
    for(int j=1;j<m+1;j++){
      if(s[i] == t[j]){
        dp[i][j] = sum[i-1][j-1]+1;
      }
      else{
        dp[i][j] = 0;
      }
      dp[i][j] %= MOD;
      sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j];
      sum[i][j] %= MOD;
    }
  }
  long long ans = sum[n][m];
  ans += 1;
  ans %= MOD;
  ans += 2ll*MOD;
  ans %= MOD;

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 62848
#include<bits/stdc++.h>
using namespace std;
const int N=2*10000+5;
const int maxn=0x3f3f3f3f;
int dp[N];

int main(){
    int h,n,x,y,i,j;
	cin>>h>>n;
    memset(dp,maxn,sizeof(dp));
    dp[0]=0;
    
    for(i=0;i<n;i++){
        cin>>x>>y;
        for(j=0;j+x<N;j++)
        dp[j+x]=min(dp[j+x],dp[j]+y);
    }
    
    int minv=maxn;
    sort(dp+h,dp+N-1);
    cout<<dp[h];
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int a[5005];
	int n;
	int i,j,k;
	int s,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	s=0,b=0,c=0;
	for(i=3;i>0;i--){
		for(j=0;j<n;j++){
			if(a[j]==i){
				if(c==0)b=j;
				c++;
			}else if(c!=0){
				if(b==0 || c%2==0)s+=c;
				else{
					if(a[j]>a[b-1])a[j]=(a[j]>0?a[j]-1:0);
					else a[b-1]=(a[b-1]>0?a[b-1]-1:0);
					s+=c+1;
				}
				for(k=b;k<b+c;k++){
					a[k]--;
				}
				b=0,c=0;
			}
		}
		s+=c;
		for(j=b;j<b+c;j++){
			a[j]--;
		}
		b=0,c=0;
	}
	cout<<s<<endl;
	return 0;
}
						

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int inf = 1001001001;
int main() {
  int n;
  cin >> n;
  vector<int> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  int mi,ma;
  mi = inf, ma = -inf;
  rep(i,n){
    mi = min(mi,x[i]+y[i]);
    ma = max(ma,x[i]+y[i]);
  }
  int ans = ma-mi;
  mi = inf, ma = -inf;
  rep(i,n){
    mi = min(mi,x[i]-y[i]);
    ma = max(ma,x[i]-y[i]);
  }
  ans = max(ans,ma-mi);
  cout << ans << endl;
}


Measured memory_bytes: 4820
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n);
	uint32 o = 0;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
		if (a[i] & 1)++o;
	}
	std::cout << ((o & 1) ? "NO\n" : "YES\n");
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
//#define INF 1145141919
#define INF 2147483647
#define MOD 1000000007
#define MAX_N (1<<17) // 10^5

struct SegTree {
  long long seg[MAX_N*2-1];
  int lazy[MAX_N*2-1];
  SegTree() {
    for (int i=0; i<MAX_N*2-1; i++) seg[i] = 0, lazy[i] = 0;
  }

  inline void setLazy(int k, int v, int l, int r) {
    lazy[k] += v;
    seg[k] += 1LL*v*(r-l);
  }
  inline void fix(int k) {
    seg[k] = seg[k*2+1] + seg[k*2+2];
  }
  inline void push(int k, int l, int r) {
    if (lazy[k] == 0) return;
    setLazy(k*2+1, lazy[k], l, (l+r)/2);
    setLazy(k*2+2, lazy[k], (l+r)/2, r);
    lazy[k] = 0;
  }

  void fill(int a, int b, int x, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      setLazy(k, x, l, r);
      return;
    }
    push(k, l, r);
    fill(a, b, x, k*2+1, l, (l+r)/2);
    fill(a, b, x, k*2+2, (l+r)/2, r);
    fix(k);
  }

  int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return seg[k];
    push(k, l, r);
    return query(a, b, k*2+1, l, (l+r)/2) + query(a, b, k*2+2, (l+r)/2, r);
  }
};

int N, Q;
SegTree seg;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  rep(i, Q) {
    int t;
    cin >> t;
    if (t == 0) {
      int l, r, x;
      cin >> l >> r >> x;
      seg.fill(l, r+1, x);
    }
    else {
      int i;
      cin >> i;
      cout << seg.query(i, i+1) << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n;
vi w;
int dp[333][333];
vector<vector<bool>> del;

int del_all(int left, int right)
{
	if (dp[left][right] >= 0) return dp[left][right];
	int res = 0;
	if (left > right) res = 0;
	else if (left == right) res = 1;
	else
	{
		FOR(i, left + 1, right)
		{
			if (del_all(left, i) && del_all(i, right)) res = 1;
			if (abs(w[left] - w[right - 1]) <= 1 && del_all(left + 1, right - 1)) res = 1;
		}
	}
	return dp[left][right] = res;
}

int dp2[333];

int solve(int p)
{
	if (dp2[p] >= 0) return dp2[p];
	if (p == n) return 0;
	int res = 0;
	chmax(res, solve(p + 1));
	FOR(i, 1, n + 1)
	{
		if (del[p][i])
		{
			chmax(res, i - p + solve(i));
		}
	}
	return dp2[p] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	while (cin >> n, n)
	{
		MS(dp, -1);
		MS(dp2, -1);
		w.resize(n);
		REP(i, n) cin >> w[i];
		int ans = 0;
		del.clear();
		del.resize(n + 1, vector<bool>(n + 1));
		REP(i, n + 1)REP(j, i)
		{
			if (del_all(j, i))
			{
				del[j][i] = true;
			}
		}
		cout << solve(0) << endl;
	}
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int n;
string s;

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

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

ifstream fin("pentagon.in");
ofstream fout("pentagon.out");

#define NMAX 1005

int v[NMAX];

bool comp(int a,int b)
{
   return a>b;
}

int main()
{
   int n,m;
   cin>>n>>m;
   int sum = 0;

   for(int i=0;i<n;i++)
   {
      cin>>v[i];
      sum+=v[i];
   }
   sort(v,v+n,comp);


   if(v[m-1] >= ceil(sum / (double)(4*m)))
      cout<<"Yes";
   else
      cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3.4

# abc126_e

import sys

sys.setrecursionlimit(10**5+4)

def main():
    # input
    n, m = [int(s) for s in input().split()]
    to = [list() for _ in range(n)]
    for _ in range(m):
        x, y, _ = [int(s) for s in input().split()]
        x -= 1
        y -= 1
        to[x].append(y)
        to[y].append(x)
    # get ans
    colors = [None] * n
    counter = 0
    def dfs(cur, c):
        if colors[cur] != None:
            return
        colors[cur] = c
        for i in to[cur]:
            dfs(i, c)
    for i in range(n):
        if colors[i] == None:
            dfs(i, counter)
            counter += 1
    ans = counter
    # output
    print(ans)

if __name__ == '__main__':
    main()



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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  string s;
  cin >> s;
  set<char> st;
  bool ok = true;
  for(int i = 0; i < (int)s.size(); i++) {
    if(st.count(s[i]) == 0) st.insert(s[i]);
    else ok = false;
  }
  if(ok) {
    cout << "yes" << endl;
    return 0;
  }
  else {
    cout << "no" << endl;
    return 0;
  }
} 

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll a, b;
    cin >> a >> b;
    if(a <= b){
        rep(i, b)cout << a;
    }
    else {
        rep(i, a)cout << b;
    }
}

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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2])
    cout << "Yes" << endl;
  else if(s[1] == s[2] && s[2] == s[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=1,A,a;cin>>N;
  REP(i,N){
    cin>>A;a=ans;
    if(A==0)ans=0;
    if(ans!=-1)ans*=A;
    if(ans>1000000000000000000||ans<0||(ans<a&&A!=0))ans=-1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)


func main() {

	var n int

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 100000)

	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	array := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		array[i], _ = strconv.Atoi(sc.Text())
	}

	num, index := 0, 1
	i := 0
	for i = 0; i < n; i++ {
		if array[i] == index {
			index++
		} else {
			num++
		}
	}
	
	if index == 1 {
		fmt.Println(-1)
	} else {
		fmt.Println(num)
	}

}


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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
    int x,y;
    cin>>x>>y;
    int z;
    for(int i=0;i<=x;i++){
    	z = x-i;
    	if(z*4+i*2==y){
    		cout<<"Yes";
    		return 0;
    	}
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3604
M, K = map(int, input().split())
maxim = 2 ** M

if maxim <= K:
    print("-1")
else:
    if maxim == 1 and K == 0:
        print("0 0")
    elif maxim == 2:
        if K == 0:
            print("0 0 1 1")
        elif K == 1:
            print("-1")
    else:
        for i in range(maxim):
            if i != K:
                print(str(i), end=" ")
        print(str(K), end=" ")
        for i in range(maxim - 1, -1, -1):
            if i != K:
                print(str(i), end=" ")
        print(str(K))


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

int main() {
  vector<long> cap(5);
  long n;
  cin >> n;
  for(int i=0; i<5; i++){
    cin >> cap.at(i);
  }
  vector<long>::iterator minIt = min_element(cap.begin(), cap.end());
  int minIdx = distance(cap.begin(), minIt);
  long min = cap.at(minIdx);
  long ans = 4 + n / min;
  if ( n % min != 0){
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter
N=int(input())
A = list(map(int,input().split()))
Ac = Counter(A)
kind = len(Ac)
Av = sum(i-1 for i in Ac.values() if i != 1)
if Av%2 == 0:
    print(kind)
else:
    print(kind-1)

Measured memory_bytes: 18656
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
void solve()
{
   ll n;
   cin>>n;
   ll cnt=0;
   for(int i=1;i<=n-1;i++)
   {
      ll op=(n-1)/i;
      ll oi=n-1-(op*i);
      if(n%i!=0&&oi>=n%i)
        cnt++;
      cnt+=op;
     // cout<<cnt<<endl;
   }
   cout<<cnt;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define pb push_back
#define INF 1e9
#define PI 3.1415926535
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORN(a,m,n,p) for(int a=m;a<n;a+=p)
#define REP(a,m,n) for(int a=m;a<n;a++)
#define frestream freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define sz(a) a.size()
typedef long long ll;
using namespace std;

int main(){
	int x,a;
	cin>>x>>a;
	if(x<a)cout<<0<<endl;
	else cout<<10<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdlib>

using namespace std;

struct Node
{
    int data;
    struct Node *prev;
    struct Node *next;
};

struct DoubleLinkedList
{
    struct Node *head;
    struct Node *tail;
    int n;

    void init()
    {
        head = tail = NULL;
    }

    struct Node* find(int x)
    {
        struct Node *curr;
        curr = head;
        while(curr != NULL)
        {
            if(curr->data == x)
                return curr;
            curr = curr->next;
        }
        return NULL;
    }

    bool empty()
    {
        return head == NULL;
    }

    void insert(int x)
    {
        struct Node *t = (struct Node *)malloc(sizeof(Node));
        t->data = x;
        t->prev = NULL;
        if(head == NULL)
            head = tail = t;
        else
        {
            head->prev = t;
            t->next = head;
            head = t;
        }
    }

    void deleteFirst()
    {
        if(head == tail)
            head = tail = NULL;
        else
        {
            struct Node *t = head->next;
            t->prev = NULL;
            head = t;
        }
    }

    void deleteLast()
    {
        if(head == tail)
        {
            head = tail = NULL;
        }
        else
        {
            struct Node *t = tail->prev;
            t->next = NULL;
            tail = t;
        }
    }

    void deleteX(int x)
    {
        struct Node *curr = find(x);
        if(curr)
        {
            if(curr == head)
                deleteFirst();
            else if(curr == tail)
                deleteLast();
            else 
            {
                curr->next->prev = curr->prev;
                curr->prev->next = curr->next;
            }
        }
    }
};

struct DoubleLinkedList l;

int main()
{
    int n;
    string cmd;
    l.init();
    cin>>n;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin>>cmd;
        if(!cmd.compare("deleteFirst"))
            l.deleteFirst();
        else if(!cmd.compare("deleteLast"))
            l.deleteLast();
        else if(!cmd.compare("delete"))
        {
            cin>>x;
            l.deleteX(x);
        }
        else if(!cmd.compare("insert"))
        {
            cin>>x;
            l.insert(x);
        }

    }

    struct Node *curr = l.head;
    while(curr != NULL)
    {
        if(curr->next == NULL)
            cout<<curr->data<<endl;
        else
            cout<<curr->data<<" ";
        curr = curr->next;
    }
}


Measured memory_bytes: 37524
#include<stdio.h>

int F(int);
int Fib[45];
int main()
{
  int n,i;
  for(i=0;i<45;i++)Fib[i]=0;
  scanf("%d",&n);
  printf("%d\n",F(n));
  return 0;
}

int F(int n)
{
  if(n==0||n==1)return Fib[n]=1;
  if(Fib[n]!=0)return Fib[n];
  return Fib[n]=F(n-1)+F(n-2);
}
  


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

int main(){
  int a, b, c;
  cin >> a >> b;
  c = (a * b) % 2;
  //cout << a << b << c;
  if (c == 1){
    cout << "Odd" << endl;
  }
  else if (c == 0){
    cout << "Even" << endl;
  } 
}

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

int main() {

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

    int mx = 0;
    rep(i, n){
        if(i){
            mx = max(mx, a[i] - a[i-1]);
        }
        else{
            mx = max(mx, k+a[0]-a[n-1]);
        }
    }
    cout << k - mx << endl;

    return 0;
}


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

int main(int argc, const char * argv[]) {
    int x,y;
    int result=0;
    cin >> x;
    cin >> y;
    
    if (x == 1 && y == 1) {
        cout << "1000000";
        return 0;
    }
    
    if (x == 1) {
        result += 300000;
    }else if(x==2){
        result += 200000;
    }else if(x==3){
        result += 100000;
    }
    if (y == 1) {
        result += 300000;
    }else if(y==2){
        result += 200000;
    }else if(y==3){
        result += 100000;
    }

    cout << result;
    
    return 0;
}


Measured memory_bytes: 256
<?php
  $inp = explode(' ', fgets(STDIN));

  for ($i = 0; $i < 2; $i++) {
    $inp[$i] = intval($inp[$i]);
  }

  if ($inp[0] === 0 && $inp[1] === 0) {
    echo '-1';
    return;
  }

  for ($i = 1; $i <= 1009; $i++) {
    if (intval($i * 0.08) === $inp[0] && intval($i * 0.1) === $inp[1]) {
      echo $i;
      return;
    }
  }

  echo '-1';

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define N 200010
using namespace std;
long long l,r,mid,n,k,a[N],t=0;
long long j(long long x)
{
    long long spj=0;
    for(long long i=0;i<n;i++)spj+=(a[i]-1)/x;
    return spj;
}
signed main()
{
    cin>>n>>k;
    for(long long i=0;i<n;i++)scanf("%lld",&a[i]),t=max(t,a[i]);
    l=1,r=t;
    while(l!=r)
    {
        mid=(l+r)/2;
        if (j(mid)<=k) r=mid;
        else l=mid+1;
    }
    cout<<r;
}

Measured memory_bytes: 5216
// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

vector<string> Z { "NO", "YES" };

#include <set>
void solve() {
  string s; int n;
  cin >> n >> s; 
  int cnt = 0;
  loop(i,2,n) {
    cnt += s[i-2] == 'A' and s[i-1] == 'B' and s[i] == 'C';
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string s, t;
  std::cin >> N >> s >> t;

  i64 offset;
  for (offset = 0; offset <= N; ++offset) {
    bool matched = true;
    for (i64 i = offset, j = 0; i < N; ++i, ++j) {
      if (s[i] != t[j]) {
        matched = false;
        break;
      }
    }
    if (matched) break;
  }

  std::cout << N + offset << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n,m;
vector<vi> table;
vi p;
ll ans;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    table.resize(n+1);//table[i][1,2,..] := iにつながる電球
    ll inp,inp2;
    rep(i,m){
        cin>>inp;
        rep(j,inp){
            cin>>inp2;
            table[inp2].pb(i+1);
        }
    }
    ans = 0;
    bool  flg;
    p.resize(m+1);
    rep(i,m)cin>>p[i+1];
    vi tmp; tmp.resize(m+1);
    rep(mask,1<<n){
        rep(i,n){
            if(mask & (1<<i)){
                rep(j,table[i+1].size()){
                    tmp[table[i+1][j]]+=1;
                }
            }
        }
        flg = true;
        rep(j,m){
            if(tmp[j+1] %2 != p[j+1])flg = false;
        }
        if(flg)ans++;
        rep(i,tmp.size())tmp[i]=0;
    }
    print(ans);
    return 0;
}

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

	string s;
	string answer;

	cin >> s;

	answer = s[0];

	for (int i = 1; i < s.size(); i++) { 
		
		if (i % 2 == 0 ) {
			answer = answer + s[i];
		}
	}

	cout << answer << endl;

	return 0;

}

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;

    vector<int> L(N);
    REP(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    int ans = 0;
    for (int r=N-1; r>=1; r--) {
        for (int mid=r-1; mid>=0; mid--) {
            auto iter = lower_bound(all(L), L[r]+L[mid]);
            int ng = distance(iter, L.end());
            ans += N - (r+1)- ng;
        }
    }
    print(ans);
}

signed main() {
    solve();
}


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


def solve(N: int, H: int, W: int, A: "List[int]", B: "List[int]"):
    answer = 0
    for i in range(N):
        if H <= A[i] and W <= B[i]:
            answer += 1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, H, W, A, B)

if __name__ == '__main__':
    main()


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

#define N 200
int h[N][N];
int top[N][N];
int R[6][6];
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
class Dice{
public:
  int t,f,r,x,y,z;
  Dice(int a,int b){
    t = a;
    f = b;
    r = R[a][b];
    x = y = N/2;
    z = h[y][x];
  }
  int movedir(){
    int num[] = {5-f,r,f,5-r};
    int ret = -1;
    int maxnum = 2;
    for(int i=0;i<4;++i){
      if(maxnum < num[i] && h[y+dy[i]][x+dx[i]] < h[y][x]){
	maxnum = num[i];
	ret = i;
      }
    }
    return ret;
  }
  void rot(int dir){
    if(dir==-1) return;
    if(dir==0){
      int tmp = t;
      t = f;
      f = 5-tmp;
    }
    if(dir==1){
      int tmp = t;
      t = 5-r;
      r = tmp;
    }
    if(dir==2){
      int tmp = t;
      t = 5-f;
      f = tmp;
    }
    if(dir==3){
      int tmp = t;
      t = r;
      r = 5-tmp;
    }
    x+=dx[dir];
    y+=dy[dir];
    z = h[y][x];
  }
  void move(){
    while(true){
      int d = movedir();
      if(d==-1) break;
      rot(d);
    }
    h[y][x]++;
    top[y][x]=t;
  }
};

int main(){
  string s[] = {"-2413-",
		"3-05-2",
		"15--04",
		"40--51",
		"2-50-3",
		"-3142-"};
  for(int i=0;i<6;++i)
    for(int j=0;j<6;++j)
      if(s[i][j]!='-')
	R[i][j] = s[i][j]-'0';
  int n;
  while(cin>>n,n){
    memset(top,-1,sizeof(top));
    memset(h,0,sizeof(h));
    for(int i=0;i<n;++i){
      int t,f;
      cin >> t >> f;
      t--;
      f--;
      Dice d = Dice(t,f);
      d.move();
    }
    int hist[6]={};
    for(int i=0;i<N;++i)
      for(int j=0;j<N;++j)
	if(top[i][j]>=0) hist[top[i][j]]++;
    for(int i=0;i<5;++i) cout << hist[i] << " ";
    cout << hist[5] << endl;
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b;
	int sum;
	string str;
	string s,t;
	char c;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 

	//cin >> a >> b;
	//cin >> a >> b >> m;
	//cin >> str;
	cin >> n;
	
	//cin >> s >> t;
	//cin >> c;

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {

	cout << (1+n)*n/2 << endl;


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<pair<string,bool> >v;
    string a,b;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      v.push_back(make_pair(a,1));
      v.push_back(make_pair(b,0));
    }
    sort(v.begin(),v.end());
    int ans=0,k=0;
    for(int i=0;i<v.size();i++){
	if(v[i].second)k++;
	else k--;
	ans=max(k,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    int f=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    
   {if(a[i]%2==0)
    {
        if(a[i]%3==0 || a[i]%5==0)
     {  
        f =0;
                }
        else
           {
        f=1;
        break;
                }
    }
        }
    if(f==0)
    printf("APPROVED\n");
    else if(f==1)
    printf("DENIED\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int ans[100][100];
int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int i = 0;
  rep(c,n){
    int a;
    cin >> a;
    rep(_,a){
      ans[i/w][i%w] = c+1;
      ++i;
    }
  }
  rep(i,h)rep(j,w) cout << ans[i][i%2==0?j:w-1-j] << (j==w-1?'\n':' ');
}

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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;

int main()
{



	IOS;

	int n, l;
	cin >> n >> l;



	vector<string>s(n);

	loop(i, n)
	{
		cin >> s.at(i);
	}

	sort(s.begin(), s.end());

	loop(i, n)
	{
		cout << s.at(i);
	}




	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> count(200010);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
    }

    ll ret = 0;
    for (auto x:count)ret += x * (x - 1) / 2;

    for (int i = 0; i < n; i++) cout << ret - (count[a[i]] - 1) << endl;
    return 0;
}

Measured memory_bytes: 4992
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: chars,
    }
    let mut s = s;
    s.sort();
    puts!("{}\n", if s[0] == 'A' && s[2] == 'B' { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m and n>0){
		int a[n],b[m],suma=0,sumb=0;
		rep(i,n){
			cin>>a[i]; suma+=a[i];
		}
		rep(i,m){
			cin>>b[i]; sumb+=b[i];
		}
		int ans=100000,ans1=101,ans2=101;
		int sum=suma+sumb;
		if(sum%2==0){
			sum/=2;
			rep(i,n){
				rep(j,m){
					if(sum==suma-a[i]+b[j]){
						if(ans>a[i]+b[j]){
							ans=a[i]+b[j]; ans1=a[i]; ans2=b[j];
						}
					}
				}
			}
		}
		if(ans1==101) cout<<"-1"<<endl;
		else cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}



Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long N=gi();
	    String S= gs();
	    long[] K=new long[26];
	    for(int i=0;i<N;i++) {
	    	char c=S.charAt(i);
	    	K[c-97]++;
	    }
	    long a=1;
	    for(int i=0;i<K.length;i++) {
	    	if(K[i]==0) continue;
	    	a*=K[i]+1;
	    	a=a%1000000007;
	    }
	    a=(a+1000000006)%1000000007;
//	    if (k>k2) {
//	    	System.out.println("NO");
//	    } else {
//	    	System.out.println("YES");
//	    }
	    System.out.println(a);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll k, x; cin>>k>>x;
  ll upper=x+k-1;
  ll lower=x-k+1;
  
  for(ll i=lower; i<=upper; i++) cout << i <<" ";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r=1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  string S;
  cin >> S;
  i64 N = S.size();

  vi C(N+1,0);
  rep(i,N){
    C[i+1] = (C[i] + (S[N-1-i] - '0')*pow_mod(10,i,2019))%2019;
  }

  vi cnt(2019,0);
  rep(i,N+1){
    cnt[C[i]]++;
  }

  i64 ans = 0;
  rep(i,2019){
    ans += cnt[i] * (cnt[i] - 1) /2;
  }

  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 5184
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long mod = 998244353;
long long fact[1 << 18], inv[1 << 18];
long long N, M, K;

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 250000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 250000; i++) inv[i] = Div(1, fact[i], mod);
}

long long ncr(int n, int r) {
	return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}

int main() {
	init();
	cin >> N >> M >> K;

	long long sum = 0;
	for (int i = 0; i <= K; i++) {
		long long t1 = ncr(N - 1, i);
		long long t2 = modpow(M - 1, (N - 1) - i, mod);
		sum += (t1 * t2 % mod) * M % mod;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7492
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n;
    cin>>n;
    printf("%.9f\n", ((int)(n+1)/2)/n);
}

Measured memory_bytes: 256
INFTY = 10**8
H,N = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[INFTY for j in range(H+1)] for i in range(N+1)]
for i in range(N+1):
    dp[i][0]=0
for i in range(1,N+1):
    for j in range(1,H+1):
        dp[i][j] = dp[i-1][j]
        if j<=A[i-1][0]:
            dp[i][j] = min(dp[i][j],A[i-1][1])
        else:
            dp[i][j] = min(dp[i][j],dp[i][j-A[i-1][0]]+A[i-1][1])
print(dp[N][H])

Measured memory_bytes: 160972
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, M = readnums()
    xy = [tuple(readnums()) for _ in range(M)]
    dic = {i: 1 for i in range(1, N + 1)}
    r = {1}
    for (x, y) in xy:
        dic[x] -= 1
        dic[y] += 1
        if x in r:
            r.add(y)
            if not dic[x]:
                r.remove(x)

    print(len(r))


if __name__ == "__main__":
    main()


Measured memory_bytes: 32624
#include <cstdio>

int main(){
	int n;
	while(scanf("%d", &n),n){
		int ans = 0;
		for(int i = 0; i < n/4; i++){
			int p; scanf("%d", &p);
			ans += p;
		}
		printf("%d\n", ans);
	}
}

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

using namespace std;

int main(){

string S;
cin>>S;

int flag {3};

//1
if(S[0]!='A'){
    flag--;
}

//2
int C_count {0};
for(int i {2}; i<S.length()-1; i++){
    if(S[i]=='C'){
        C_count++;
    }
}
if (C_count!=1){
    flag--;
}

//3
int lower_count {0};
for(int j {0}; j<S.length(); j++){
    if(S[j]>='a' && S[j]<='z'){
        lower_count++;
    }
}
if(lower_count!=S.length()-2){
    flag--;
}

if(flag==3){
    cout<<"AC";
}else{
    cout<<"WA";
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int solve(){
	int N,M;
	cin >> N >> M;
	if(N+M==0)return 1;
	vector<int> d(N),v(N);
	vector<int> mx(M);
	for(int i=0;i<N;i++){
		cin >> d[i] >> v[i];
		d[i]--;
		mx[d[i]]=max(mx[d[i]],v[i]);
	}
	int ans = 0;
	for(int i=0;i<M;i++)ans += mx[i];
	cout << ans << endl;
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if ( a % 3 == 0 || b % 3 == 0 | ( a + b) % 3 == 0){
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
  
 }


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

int h, w, d;

int main() {
	cin >> h >> w >> d;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a = ((i + j + 1000) / d) % 2;
			int b = ((i - j + 1000) / d) % 2;
			cout << "RGBY"[a * 2 + b];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
S = input()
S += '0'
max = 0
count = 0
for i in range(len(S)) :
    if S[i] == 'A' or S[i] =='C' or S[i] =='G' or S[i] =='T' :
        count += 1 
    else :
        if count > max :
            max = count
            count = 0

print(max)

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,k,x,y;
	t = 1;
	while(t--) {
	 cin >> n >> k >> x >> y;
	 if(n <= k)
	  cout << n * x << endl;
	 else
	  cout << k * x + (n - k) * y << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		String str = stdIn.next();
		int index = 0;
		String[][] s = new String[10000][2];
		double x = 0;
		double y = 0;
		double angle = 90;

		while( !str.equals("0,0") ){
			s[index] = str.split(",");
			int r = Integer.parseInt(s[index][0]);			
			x += r*Math.cos((angle%360)*Math.PI/180);
			y += r*Math.sin((angle%360)*Math.PI/180);
			str = stdIn.next();angle -= Integer.parseInt(s[index][1]);
			index++;
		}
		
		System.out.println((long)x);
		System.out.println((long)y);
	}
}

Measured memory_bytes: 12000