akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

static const int MAX = 10000;
static const int INFTY = 1000000000;
static const int WHITE = 0, BLACK = 2;

int n;
int A[MAX][MAX];
int d[MAX], color[MAX];
vector<pair<int, int> > G[MAX];

void sssp() {
	priority_queue<pair<int, int> > PQ;
	for (int i = 1; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	PQ.push(make_pair(0, 0));

	while (!PQ.empty()) {
		pair<int, int> u = PQ.top();
		PQ.pop();
		int t = u.second;

		if (d[t] < u.first * (-1)) continue;
		color[t] = BLACK; 

		for (int j = 0; j < G[t].size(); j++) { 
			int v = G[t][j].first;
			if (color[v] != BLACK) { //??£??\?????????????????§???????????????
				if (d[v] > d[t] + G[t][j].second) {
					d[v] = d[t] + G[t][j].second;
					PQ.push(make_pair(d[v] * (-1), v)); //????????????????????????????????????
				}
			}
		}
	}
}

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int u, k, v, c;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			G[u].push_back(make_pair(v, c));
		}
	}

	sssp();

	for (int i = 0; i < n; i++) {
		cout << i << ' ' << d[i] << endl;
	}

	return 0;
}

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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}

int main() {
	long N, X; cin >> N >> X;
	long x[110000];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	x[N] = X;
	sort(x, x + N+1);
	for (int i = 0; i < N; i++) {
		x[i] = x[i + 1] - x[i];
	}
	for (int i = 0; i < N-1; i++) {
		x[i+1]=gcd(x[i], x[i + 1]);
		if (x[i] == 1) {
			return 1;
		}
	}
	cout << x[N-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  #define int ll
  int n;cin>>n;
  vector<ll> a(n+10,0);
  for(int i = 1;i <= n;++i){
    for(int j = i;j <= n;j += i){
      a[j]++;
    }
  }

  ll ans = 0;
  for(int i = 1;i <= n;++i){
    ans += i * a[i];
  }
  print(ans);
  return 0;
}

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

int main() {
	int n, m, x, mn1 = 0, mn2 = 0;
	cin >> n >> m >> x;
	vector < int > a(m);

	for ( auto & i: a ) {
		cin >> i;
	}
	for ( auto i: a ) {
		if ( i > x ) {
			mn1++;
		}
		else {
			mn2++;
		}
	}
	cout << min( mn1, mn2 );  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long num = 0;			// 与えられた数
		long answer = 0;		// 正解
		double limit = 0.0;		// 探索の上限

		// 数字の入力
		num = scan.nextLong();
		answer = num;
		limit = Math.sqrt(num);

		// 該当マスの調査
		for(int i = 1; i <= limit; i++) {
			if(num % i == 0 && (num / i) + i - 2 < answer) {
				answer = (num / i) + i - 2;
			}
		}

		// 結果の出力
		System.out.println(answer);

	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    vector<int>l(n);
    vector<int>r(n);
    l[0]=v[0];r[0]=v[n-1];
    rep(i,n-1){
        l[i+1]=l[i]+v[i+1];
        r[i+1]=r[i]+v[n-2-i];
    }
    int ans = 0;
    rep(i,k+1){
        rep(j,i+1){
            vector<int>bag;
            rep(l,j){
                if(bag.size()==n)continue;
                bag.push_back(v[l]);
            }
            rep(l,i-j){
                if(bag.size()==n)continue;
                bag.push_back(v[n-1-l]);
            }
            sort(bag.begin(),bag.end());
            rep(l,min(k-i,(ll)bag.size())){
                if(bag[l]<0)bag[l]=0;
            }
            int tmp = 0;
            rep(l,bag.size()){
                tmp+=bag[l];
            }
            chmax(ans,tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool a=false;
  while(N){
    int A=N%10;
    if(A==7){
      a=true;
    }
    N/=10;
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    if (A == 1) A += 13;
    if (B == 1) B += 13;
    cout << (A == B ? "Draw" : A > B ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List<Integer> arraylistX = new ArrayList<Integer>();
		List<Integer> arraylistY = new ArrayList<Integer>();
		int lastAddX;
		int lastAddY;
		do {
			lastAddX = stdIn.nextInt();
			lastAddY = stdIn.nextInt();
			arraylistX.add(lastAddX);
			arraylistY.add(lastAddY);
			
		}while(lastAddX != 0 || lastAddY != 0);
		
		for(int i = 0; i < arraylistX.size()-1; i++) {
			if(arraylistX.get(i) < arraylistY.get(i)) {
				System.out.println(arraylistX.get(i) + " " + arraylistY.get(i));
			}
			else {
				System.out.println(arraylistY.get(i) + " " + arraylistX.get(i));
			}
		}
	}
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch;
	cin >> ch;
	if (islower(ch)) {
		cout << 'a' << '\n';
	} else {
		cout << 'A' << '\n';
	}
	return 0;
}



Measured memory_bytes: 3632
from collections import Counter
N=int(input())
A=[int(x) for x in input().split()]
B=[0]*N
left=0
for i in range(N):
  left+=A[i]
  B[i]=left
count=Counter(B)
score=0
for num,freq in zip(count,count.values()):
  if num==0:
    score+=freq*(freq-1)/2+freq
  else:
    score+=freq*(freq-1)/2
print(int(score))

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

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	vector<ll> a(n);
	for(ll &i:a)
		cin>>i;
	ll max1=a[0];
	ll ans=0;
	forn(i,1,n)
	{
		if(max1>a[i])
			ans+=max1-a[i];
		else
			max1=a[i];
	}
	cout<<ans<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


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

const i64 MOD = 1e9 + 7;

vector<i64> fac(300001);
vector<i64> ifac(300001);

i64 mpow(i64 x, i64 n)
{
  i64 ans = 1;
  while (n != 0)
  {
    if (n & 1)
      ans = ans * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return ans;
}

i64 comb(i64 a, i64 b)
{
  if (a == 0 && b == 0)
    return 1;
  if (a < b || a < 0)
    return 0;
  i64 tmp = ifac[a - b] * ifac[b] % MOD;
  return tmp * fac[a] % MOD;
}

int main()
{
  i64 n, k;
  cin >> n >> k;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  fac[0] = 1;
  ifac[0] = 1;
  for (i64 i = 0; i < 300000; i++)
  {
    fac[i + 1] = fac[i] * (i + 1) % MOD;
    ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
  }
  i64 ans = 0;
  for (i64 i = 0; i < n; i++)
    (ans += comb(i, k - 1) * a[i] - comb(n - i - 1, k - 1) * a[i]) %= MOD;
  cout << ans % MOD << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll m=1e9+7;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}
ll f[100005];
ll ncr(ll n,ll r)
{
	if(r<0||r>n)return 0;
	ll ans=(f[n]*p(f[r],m-2))%m;
	ans=(ans*p(f[n-r],m-2))%m;
	return ans;
}

int main()
{ios_base::sync_with_stdio(false);
f[0]=1;
rep(i,1,100004)f[i]=(f[i-1]*1ll*i)%m;

int n,k;
cin>>n>>k;

rep(i,1,k)
{
	ll ans=(ncr(k-1,i-1)*ncr(n-k+1,i))%m;
	ol(ans);on;
}
return 0;
}



Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
 
#define ARRAY_SIZE 10
int main()
{
	char inputN[ARRAY_SIZE];
 
	scanf("%s", &inputN);
 
	if (inputN[2] == inputN[3] && inputN[4] == inputN[5])
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}
 
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k,ans;
vector<int> v;
signed main(){
	cin>>k;
	queue<int> que;
	rep(i,9){
		que.push(i+1);
	}
	for(int i=0;i<k;i++){
		int  x=que.front();
		string y=to_string(que.front());
		if(y[y.size()-1]=='0'){
			que.push(x*10);
			que.push(x*10+1);
		}
		else if(y[y.size()-1]=='9'){
			que.push(x*10+8);
			que.push(x*10+9);
		}
		else{
			int plus=y[y.size()-1]-'0';
			que.push(x*10+(plus-1));
			que.push(x*10+(plus));
			que.push(x*10+(plus+1));
		}
		v.push_back(x);
		que.pop();
	}
	cout<<v[k-1]<<endl;
}

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

namespace _2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            Console.WriteLine(x[0] + " " + x[1] + " " + x[2]);
        }
    }
}

Measured memory_bytes: 9756
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    long tmp; vector<long> a; for(int i=0; i < N; ++i) {
        cin >> tmp;
        if(tmp < K) a.push_back(tmp);
    }
    vector<bitset<5005>> dp;

    int n = (int)a.size();
    int width = n / sqrt(n);
    int div = (n + width - 1) / width;
    dp.resize(div);
    for(int i=0; i < div; ++i) dp[i][0] = true;

    for(int i=0; i < n; ++i) {
        for(int j=0; j < div; ++j) {
            if(i / width == j) continue;
            dp[j] |= dp[j] << a[i];
        }
    }

    int ans = 0;
    for(int i=0; i < n; ++i) {
        auto tmp = dp[i / width];
        for(int j = i / width * width; j < min(n, (i / width + 1) * width); ++j) {
            if(j == i) continue;
            tmp |= tmp << a[j];
        }

        bool add = true;
        for(int k = K - a[i]; k < K; ++k) {
            if(tmp[k] == 1) {
                add = false;
                break;
            }
        }
        if(add) ++ans;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3704
import math, sys

#??°????????????????????§????°????????????¨???????????°??????????????????????§????
class SegmentTree():
    def __init__(self, n):
        self.TreeRange = pow(2, math.ceil(math.log2(n)))
        self.List = [0] * (2 * self.TreeRange - 1)

    def add(self, i, x):
        i += self.TreeRange - 1
        self.List[i] += x
        while i > 0:
            i = (i - 1) // 2
            self.List[i] += x

    def getsum(self, s, t, i=0, left=0, right=float("inf")):
        #??¢?´¢????±?????????????????????§????????°0????????????
        if right <= s or t <= left:
            return 0
        #??¢?´¢????±?????????????????????§????????°??????????????????????????????
        elif s <= left <= right <= t:
            return self.List[i]
        #??¢?´¢????±????????????????????????????????????°????????????????????°
        else:
            l = self.getsum(s, t, i * 2 + 1, left, (left + right) // 2)
            r = self.getsum(s, t, i * 2 + 2, (left + right) // 2, right)
            return l + r

_input = sys.stdin.readlines()
n,q = map(int, _input[0].split())
qlist = map(lambda x:x.split(), _input[1:])
ST = SegmentTree(n)

for q in qlist:
    cmd, x, y = map(int, q)
    if cmd == 0:
        ST.add(x - 1, y)
    elif cmd == 1:
        print(ST.getsum(x - 1,y , right = ST.TreeRange))

Measured memory_bytes: 20860
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,nl(0:2018),tmp,ans
    integer(int64), allocatable:: md(:)
    character(200000):: s

    read*, s
    n = len_trim(s)
    allocate(md(0:n-1))
    tmp=0
    nl(:) = 0
    nl(0) = 1
    md(0)=1

    do i=1,n-1
        md(i) = mod(md(i-1)*10,2019_8)
    end do

    do i=0,n-1
        tmp=mod(tmp+(ichar(s(n-i:n-i))-ichar('0'))*md(i),2019_8)
        nl(tmp)=nl(tmp)+1
    end do

    ans=0
    do i=0,2018
        ans=ans+((nl(i)*(nl(i)-1))/2)
    end do
    print'(i0)', ans
end program 

Measured memory_bytes: 4764
n, m = map(int, raw_input().split(" "))
a = [[0 for j in range(m)] for i in range(n)]
b = [0 for j in range(m)]
for i in range(n):
    a[i] = map(int, raw_input().split(" "))
for j in range(m):
    b[j] = input()
 
for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print ans

Measured memory_bytes: 6580
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b;
  std::cin >> a >> b;
  std::cout << (a-1)*(b-1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> b;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    b[i-a.at(i)]++;
  }
  int64_t c=0;
  for(int i=0;i<n;i++)
    c+=b[i+a.at(i)];
  cout<<c<<endl;
}

Measured memory_bytes: 21192
import numpy as np
s= int(input())
List = list(map(int, input().split()))
array = list()
for i in range(List[0],List[1]+1):
    if s == 1:
        array.append("OK")
        break
    if i % s == 0:
        array.append("OK")
        break
if ('OK' in array):
    print("OK")
else:
    print("NG")

Measured memory_bytes: 27128
#include <stdio.h>
#include <string.h>

int main(void){

  char a[11],b[11],c[11];
  int A,B;

  scanf("%s %s %s",a,b,c);

  A=strlen(a);
  B=strlen(b);

  if(a[A-1]==b[0]&&b[B-1]==c[0]){
    printf("YES\n");
    return 0;
  }
  printf("NO\n");

  return 0;
}


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

int main() {
  int n,x,y;

  cin >> n >> x >> y;

  vector<vector<int> > dis(n,vector<int>(n,0));
  vector<int> ans(n-1,0);

  x-=1;y-=1;
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      dis[i][j] = min(j-i,abs(x-i)+abs(y-j)+1);
      ans[dis[i][j]-1]++;
    }
  }

  // for(int i=0;i<n;i++) {
  //   for(int j=i+1;j<n;j++) {
  //     cout << dis[i][j] << " ";
  //   }
  //   cout << endl;
  // }

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

  return 0;
}


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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, a[max_n];
long long sum, x, ans = 1e18;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    for (int i = 0; i < n; ++i) {
        x += a[i];
        sum -= a[i];
        ans = min(ans, llabs(x - sum));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll h, w;
	cin>>h>>w;
	if(h==1 || w==1){
		cout<<1<<endl;
		return 0;
	}
	cout<<(h*w+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

if (x in g1 and y in g1) or (x in g2 and y in g2) or (x in g3 and y in g3):
    print('Yes')
else:
    print('No')

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n; cin>>n;
    ll ans = 1;
    bool ok = 1;
    vector<ll> a(n);
    for(int i = 0; i<n; i++){
        cin>>a[i];
        if(!a[i]) ans = 0;
    }
    
    if(!ans) return cout<<ans<<"\n", 0;
    sort(a.begin(), a.end());
    
    for(int i = 0; i<n; i++){
        if(a[i] > 1000000000000000000/ans){
            ok = 0;
            break;
        }
        ans *= a[i];
    }
    if(ok) cout<<ans<<"\n";
    else cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, d, x;
  cin >> r >> d >> x;
  int xi = x;
  for (int i = 0; i < 10; i++) {
    xi = xi * r - d;
    cout << xi << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
//#include<algorithm>
using namespace std;
int main()
{
    int n, num_2 = 0, num_4 = 0, num_not24 = 0, tmp;
    bool is_luck;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &tmp);
        if(tmp % 4 == 0)
            num_4++;
        else if(tmp % 2 == 0)
            num_2++;
        else
            num_not24++;
    }
    if(num_2 != 0)
    {
        if(num_4 >= num_not24)
            is_luck = true;
        else
            is_luck = false;
    }
    else
    {
        if(num_4 >= num_not24 - 1)
            is_luck = true;
        else
            is_luck = false;
    }
    if(is_luck)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  bool sat = false;
  string t = "CF";
  int index = 0;
  rep(i,s.length()){
    if(s[i] == t[index])++index;
    if(index == 2){
      sat = true;
      break;
    }
  }
  YesNo(sat);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;



int main() {
  int n, ac=0, wa=0, tle=0, re=0; cin>>n;
  for (int i = 0; i < n; i++) {
    string s; cin>>s;
    if(s=="AC") ac++;
    if(s=="WA") wa++;
    if(s=="TLE") tle++;
    if(s=="RE") re++;
  }
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
}


/* きょむ〜 */


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size(),ret=0;
	for (int i=0; i<n; i++)
		ret++;
	cout<<s.front()<<ret-2<<s.back()<<endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        String n = scanner.nextLine();
        char m = n.charAt(n.length()-1);
        int res = m - '0';
        switch (res) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            case 3:
                System.out.println("bon");
                break;
        }
        
    }
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, m; cin >> n >> m;
    if (!n) break;
    V<> a(n); for (auto&& e : a) cin >> e;
    V<> b(m); for (auto&& e : b) cin >> e;
    int sa = accumulate(begin(a), end(a), 0);
    int sb = accumulate(begin(b), end(b), 0);
    sort(begin(a), end(a));
    sort(begin(b), end(b));
    [&] {
      for (int e : a) for (int f : b) {
        if (sa - e + f == sb + e - f) {
          cout << e << ' ' << f << '\n';
          return;
        }
      }
      cout << -1 << '\n';
    }();
  }
}


Measured memory_bytes: 3104
from itertools import product
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = 10 ** 18
for alloc in product(range(4), repeat=N):
    La = 0
    Lb = 0
    Lc = 0
    use_a = 0
    use_b = 0
    use_c = 0
    for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

    if not all([use_a, use_b, use_c]):
        continue

    score = 0
    score += 10 * (use_a - 1)
    score += 10 * (use_b - 1)
    score += 10 * (use_c - 1)
    score += abs(A - La)
    score += abs(B - Lb)
    score += abs(C - Lc)
    ans = min(ans, score)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

int n,k;

const int MAX=100010;
int64_t fact[MAX];
int64_t fact_inv[MAX];

int64_t power(int64_t x,int64_t n)
{
    int64_t res=1;
    while(n){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
void init(){
    fact[0]=1;
    for(int i=0;i<n;i++)fact[i+1]=fact[i]*(i+1)%mod;
    fact_inv[n]=power(fact[n],mod-2);
    for(int i=n-1;i>=0;i--)fact_inv[i]=fact_inv[i+1]*(i+1)%mod;
}
int64_t comb(int64_t n,int64_t r)
{
    if(n<0||r<0||n<r)return 0;
    return (fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}

void solve() 
{
    cin>>n>>k;
    init();
    ll a[n];REP(i,n)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    REP(i,n)ans-=a[i]*comb(n-i-1,k-1),ans=(ans+a[i]*comb(i,k-1))%mod;
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 2560
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s_sub : String = read();
    let mut s:Vec<char> = s_sub.chars().collect();
    s.sort();
    s.dedup();

    let a = 'a' as u8;
    let mut alphas:Vec<char> = (a..a+26).map(|x| x as char).collect();
    for i in 0..26 {
        if !s.contains(&alphas[i]){
            return println!("{}",alphas[i]);
        }
    }
    println!("None");
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	rep(i,n-2)if(s.substr(i,3)=="ABC")cnt++;
	cout<<cnt<<endl;
}

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

void solve(ll H,ll h,ll m,ll s){
    ll x=119*H-1;
    ll ss=h*3600+m*60+s;
    ll i=((ss*x-1)/(3600*H))+1;
    //cout<<i<<endl;
    if(i==x)i=1;
    ll ans=3600*H*i;//(119*H-1);
    //cout<<ts<<endl;//%(3600*12*60)<<endl;
    //ts%=x*60;
    //ll ts=ans  
    //ll tm=((ans-1)/x+1)/60%60;
    ll tm=(ans/x)/60%60;
    ll th=(ans/x)/3600%H;
    ans%=(x*60);
    for(int i=2;i<=x;i++){
        while(ans%i==0&&x%i==0){
            ans/=i;x/=i;
        }
    }
    cout<<th<<" "<<tm<<" "<<ans<<" "<<x<<endl;
}


int main(void){
    ll a,b,c,d;
    while(cin>>a>>b>>c>>d,a){
        solve(a,b,c,d);
    }
}



Measured memory_bytes: 3032
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();
        String n[] = new String[N];
        int ans = 0;
        int count0 = 0;
        int count1 = 0;
        
        for(int i = 0 ; i < N ; i++){
                n[i] = String.valueOf(S.charAt(i));
                if(n[i].equals("0")){
                    count0++;
                }else if(n[i].equals("1")){
                    count1++;
                }
        }      
        
        if(count0 == count1){
            ans = N;
        }else if(count0 > count1){
            ans = count1 * 2;
        }else{
            ans = count0 * 2;
        }
        
        System.out.print(ans);
        
    }
    
}


Measured memory_bytes: 30160
N=int(input())
l=["AC","WA","TLE","RE"]
a=[0,0,0,0]
for i in range(N):
    S=input()
    for j in range(4):
        if l[j]==S:
            a[j]+=1
            break
for i in range(4):
    print(f"{l[i]} x {a[i]}")

Measured memory_bytes: 9196
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
      return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
     n= int(sys.stdin.readline())
     a= list(map(int, sys.stdin.readline().split()))
     b= list(map(int, sys.stdin.readline().split()))

     ans = 0
     for i in range(n):
          ans += min(a[i]+a[i+1],b[i])
          if a[i] < b[i]:
               a[i+1] = a[i+1] - (b[i]-a[i])
               if a[i+1]<0:
                    a[i+1]=0
     print(ans)


Measured memory_bytes: 20664
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define MOD 1000000007
using namespace std;

int main(){
  int n, m, p;
  string s;
  long int sum_ac = 0, sum_wa = 0;
  cin >> n >> m;
  vector<vector<int> > v(n, vector<int>(2, 0));
  rep(i, m){
    cin >> p >> s;
    if(s == "WA" && v[p-1][0]==0){
      v[p-1][1]++;
    }else if(s == "AC"){
      v[p-1][0]++;
    }
  }
  rep(i, v.size()){
    if(v[i][0] > 0){
      sum_ac++;
      sum_wa += v[i][1];
    }
  }
  cout << sum_ac << " " << sum_wa << endl;
  return 0;
} 


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

}



Measured memory_bytes: 26472
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int toInt(const string &s){
    if(s[0] == '-')
        return -(s[1] - '0');
    return (s[0] - '0');
}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    ll n,m;
    cin >> n >> m;
    if(n >= m)
        cout << m / 2 << '\n';
    else{
        ll ans = 0;
        ll aux = min(n,m / 2);
        ans += aux;
        m -= aux * 2;
        if(m > 0)
            ans += m / 4;
        cout << ans << '\n';

    }
    return 0;
}

Measured memory_bytes: 256
r,c = map(int,input().split())
xlx = []
for i in range(r):
    xlx.append(list(map(int,input().split()))+[0])
xlx.append([0 for i in range(c+1)])

for i in range(r):
    xlx[i][-1] = sum(xlx[i])
for i in range(c):
    tmp = 0
    for j in range(r):
        tmp += xlx[j][i]
    xlx[-1][i] = tmp

s = 0
for i in range(r):
    s += sum(xlx[i])-max(xlx[i])
xlx[-1][-1] = s

for i in range(r+1):
    print(*xlx[i])


Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int a[maxn];
long long ans;
vector <pair<int, int>> p;
vector <int> g[maxn];
vector <long long> ans1;
void dsu(int v, int u){
	if((int)g[v].size() < (int)g[u].size())
		swap(v, u);
	if(v != u){
		ans += ((long long)g[v].size() * (int)g[u].size());
		for(auto x : g[u]){
			a[x] = v;
			g[v].push_back(x);
		}
	}
}
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n ; i++){
		a[i] = i;
		g[i].push_back(i);
	}
	for(int i = 0; i < m; i++){
		int v, u;
		cin >> v >> u;
		v--, u--;
		p.push_back({v, u});
	}
	reverse(p.begin(), p.end());
	ans1.push_back((long long)n * (n - 1) / 2);
	for(int i = 0; i < (int)p.size() - 1; i++){
		dsu(a[p[i].first], a[p[i].second]);
		ans1.push_back(((long long)n * (n - 1) / 2) - ans); 
	}
	reverse(ans1.begin(), ans1.end());
	for(auto x : ans1)
		cout << x << "\n";
}


Measured memory_bytes: 12916
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n;
    cin >> n;
    rep(i, n) {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3524
#include<cstdio>

const int p[] = { 6000, 4000, 3000, 2000 };

int main()
{
	for( int i = 0; i != 4; ++i )
	{
		int t, n;
		scanf( "%d%d", &t, &n );
		printf( "%d\n", p[t-1]*n );
	}

	return 0;
}

Measured memory_bytes: 1032
import Data.List
main = do
  n <- read <$> getLine
  s <- sequence $ replicate n $ do
        a <- read <$> getLine
        sequence $ replicate a $ do
          [x,y] <- map read . words <$> getLine
          return (x,y)
  print $ maximum $ length <$> filter (o s) (subsequences [1..n])
o s k = and [(y == 0) /= (x `elem` k) | i <- k,(x,y) <- s !! (i-1)]

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

#define Nmax 2005

using namespace std;

int N;
int A[Nmax];
int S;
bitset <2000002> dp[Nmax];

int main()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i], S += A[i];
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++)
        dp[i] = dp[i - 1] | (dp[i - 1] << A[i]);
    for(int j = S / 2; j >= 0; j--)
        if(dp[N][j])
        {
            cout << S - j << "\n";
            return 0;
        }
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i*m+j*n-2*i*j==k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll n, a[21][21], dp[1<<21];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    FOR(i, 0, n) {
        FOR(j, 0, n) {
            cin >> a[i][j];
        }
    }

    dp[0] = 1;
    FOR(i, 1, 1<<n) {
        int cnt = 0;
        FOR(j, 0, n) if (i & (1<<j)) cnt++;
        FOR(j, 0, n) {
            if ((i & (1<<j)) && a[cnt - 1][j]) {
                dp[i] = (dp[i] + dp[i - (1<<j)]) % MOD;
            }
        }
        // cout << i << ' ' << cnt << ' ' << dp[i] << '\n';
    }
    cout << dp[(1<<n) - 1] << '\n';
    return 0;
}

Measured memory_bytes: 16640