akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
    {
        static void Main(string[] args)
        {
            int[] ab = new int[2];
            int[] results = new int[3];
            int max = -10000;
            int i;
            string[] input = Console.ReadLine().Split(' ');
            for (i = 0; i < 2; i++)
            {
                ab[i] = int.Parse(input[i]);
            }
            results[0] = ab[0] + ab[1];
            results[1] = ab[0] - ab[1];
            results[2] = ab[0] * ab[1];

            for (i = 0; i < 3; i++)
            {
                if(results[i] > max)
                {
                    max = results[i];
                }
            }
            Console.WriteLine(max);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define MX 100000
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;

ll n,w;
ll we[105];
ll val[105];
ll dp[105][100005];

ll solve(ll pos,ll cap)
{
    if(cap==0||pos>n)
        return 0;
    if(dp[pos][cap]!=-1)
        return dp[pos][cap];

    ll ret1=0;
    ll ret2=0;
    if(we[pos]<=cap)
        ret1=val[pos]+solve(pos+1,cap-we[pos]);
    ret2=solve(pos+1,cap);

    return dp[pos][cap]=max(ret1,ret2);
}
int main()
{
    memset(dp,-1,sizeof dp);
    sc2(n,w);
    for(ll i=1; i<=n; i++)
    {
        sc2(we[i],val[i]);
    }
    ll ans=solve(1,w);
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  int N;
  string s;
  cin >> N;
  for (int i = 0; i < N;) {
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    i++;
    if (i == N)
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S=input()

l = len(S)
l_cnt = [0] * (l+1)
r_cnt = [0] * (l+1)
cnt = [0] * (l+1)
for i in range(l):
    if S[i] == '<':
        l_cnt[i+1] = l_cnt[i]+1
for i in range(l-1, -1, -1):
    if S[i] == '>':
        r_cnt[i] = r_cnt[i+1]+1
for i in range(l+1):
    cnt[i] = max(l_cnt[i], r_cnt[i])
print(sum(cnt))



Measured memory_bytes: 31892
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

const int N = 100000 + 5000;

vector<pair<int,int> > graph[N];

int col[N];


void dfs(int node, int pa, int dist)
{
	if (node != 1){
		col[node] = dist % 2;
	} 
	for (auto to : graph[node]){
		if (to.first == pa)
			continue;
		dfs (to.first, node, (dist + to.second) % 2);
	}
}

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

    int n; cin >> n;
    for (int i = 1; i < n; i++){
    	int u, v; cin >> u >> v;
    	int w; cin >> w;
    	graph[u].PB(MP(v,w));
    	graph[v].PB(MP(u, w));
    }
    col[1] = 0;

    dfs(1, 0, 0);

    for (int i = 1; i <= n; i++)
    	cout << col[i] << endl ;

	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int n,q,b[200005],c[200005],dp[200005],seg[1000005];
vector<int>g[200005];
int qry(int ll,int rr,int l,int r,int x)
{
	if(ll>rr||l>r)return 1e9+7;
	if(ll==l&&rr==r)return seg[x];
	int md=(l+r)/2;
	if(rr<=md)return qry(ll,rr,l,md,x*2);
	if(ll>md)return qry(ll,rr,md+1,r,x*2+1);
	return min(qry(ll,md,l,md,x*2),qry(md+1,rr,md+1,r,x*2+1));
}
void upd(int p,int v,int l,int r,int x)
{
//	cout<<p<<" "<<v<<" "<<l<<" "<<r<<" "<<x<<endl;
	if(l==r)
	{
		seg[x]=v;
		return;
	}
	int md=(l+r)/2;
	if(p<=md)upd(p,v,l,md,x*2);else upd(p,v,md+1,r,x*2+1);
	seg[x]=min(seg[x*2],seg[x*2+1]);
}
int main()
{
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		if(!b[i])c[i]=-1;else c[i]=1;
		ans+=(1-b[i]);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++){int u,v;scanf("%d%d",&u,&v);g[u].push_back(v);}
	for(int i=1;i<=n;i++)dp[i]=1e9+7,upd(i,dp[i],1,n,1);
	for(int i=1;i<=n;i++)
	{
		for(int k=0;k<g[i].size();k++)
		{
			int j=g[i][k];
			int mi=dp[i-1];
			int mii=mi;
			for(int o=max(i-1,1);o<=j;++o)mii=min(mii,dp[o]);
			mi=min(mi,qry(max(i-1,1),j,1,n,1));
//			cout<<i<<" "<<j<<" "<<mi<<" "<<mii<<endl;
			if(mi<dp[j])
			{
				dp[j]=mi;
				upd(j,mi,1,n,1);
			}
		}
//		dp[i]=min(dp[i],dp[i-1]+c[i]);
		if(dp[i]>dp[i-1]+c[i])
		{
			dp[i]=dp[i-1]+c[i];
			upd(i,dp[i],1,n,1);
		}
//        cout<<i<<" "<<dp[i]<<endl;
//        for(int i=1;i<=n;i++)if(dp[i]>=1e8)printf("INF ");else cout<<dp[i]<<" ";
//        cout<<endl;
//        for(int i=1;i<2*n;i++)if(seg[i]>=1e8)printf("INF ");else cout<<seg[i]<<" ";
//        cout<<endl;
	} 
    printf("%d\n",ans+dp[n]);
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;

  cout << min( n*a, b ) << endl;

  return 0;
}

Measured memory_bytes: 256
//This is the Property of Rishabh Agarwal
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
 
typedef long long int ll; 
const ll mod = 1000000007;

vector<pair<ll,ll> >f;
vector<ll>v;
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll ans=n*(n-1)+m*(m-1);
    ans=ans/2;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import math
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5
3
2
4
3
5"""
        output = """7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
123
123
123
123
123"""
        output = """5"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """10000000007
2
3
5
7
11"""
        output = """5000000008"""
        self.assertIO(input, output)
def resolve():
    N=int(input())
    a=[int(input()) for i in range(5)]
    m=min(a)
    print(4+math.ceil(N/m))
if __name__ == "__main__":
    resolve()

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

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

using namespace std;
using ll = long long;

int main(void)
{
  int x;
  cin >> x;
  cout << (x == 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
int n;
cin>>n;
vector<ll> a(n),b(n);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++)cin>>b.at(i);
ll cnt=0;
priority_queue<P> pq;
for(int i=0;i<n;i++)if(b[i]!=a[i])pq.push(P(b[i]-a[i],i));
while(!pq.empty()){
    P now=pq.top();
    pq.pop();
    ll bet=b[(now.se-1+n)%n]+b[(now.se+1)%n],nowcnt;
    nowcnt=(b[now.se]-a[now.se])/bet;
    cnt+=nowcnt;
    b[now.se]-=bet*nowcnt;
    if(nowcnt<=0){cout<<-1<<endl;return 0;}
    if(b[now.se]==a[now.se])continue;
    pq.push(P(b[now.se]-a[now.se],now.se));
}
cout<<cnt<<endl;
}


Measured memory_bytes: 9456
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int t,i,m;(t=s.nextInt()+s.nextInt())>0;System.out.println(m)){int[]a=new int[t];for(i=t;i-->0;)a[i]=s.nextInt();Arrays.sort(a);for(m=a[0];t-->1;)m=Math.max(m, a[t]-a[t-1]);}}}

Measured memory_bytes: 13000
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long 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;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) 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(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-8;
const long INF = 1e10;

int main(){
	int N;
	while(cin>>N&&N){
		long b[1002];
		b[0]=INF+1;
		long maxx=INF,minx=-INF;
		REP(i,N){
			string a;
			cin>>a;
			if(a=="x"){
				b[i+1]=((i+1)%2)?-INF:INF;
			}else{
				b[i+1]=toLong(a);
			}
		}
		b[N+1]=((N+1)%2)?-INF-1:INF+1;
		bool flag=true;
		FOR(i,1,N+1){
			if(i%2){
				if(b[i]>=b[i-1]||b[i]>=b[i+1]){
					flag=false;
					break;
				}else if(b[i]==-INF){
					if(b[i-1]==INF||b[i+1]==INF)flag=false;
					maxx=min(maxx,min(b[i-1],b[i+1]));
				}
			}else{
				if(b[i]<=b[i-1]||b[i]<=b[i+1]){
					flag=false;
					break;
				}else if(b[i]==INF){
					if(b[i-1]==-INF||b[i+1]==-INF)flag=false;
					minx=max(minx,max(b[i-1],b[i+1]));
				}
			}
		}
		if(!flag||maxx-minx<=1){
			cout<<"none"<<endl;
		}else{
			if(maxx-minx==2)cout<<(maxx+minx)/2<<endl;
			else cout<<"ambiguous"<<endl;
			//cout<<maxx<<" "<<minx<<endl;
		}
	}
	return 0;
}

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

int main() {
  vector<vector<char>> c(3,vector<char>(3));
  rep(i,3) {
    rep(j,3) {
      cin >> c.at(i).at(j);
    }
  }
  cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a%d!=0){
      a=a/d+1;
  }else{
      a=a/d;
  }
  if(c%b!=0){
      c=c/b+1;
  }else{
      c=c/b;
  }
 
  if(c<=a){
      cout << "Yes";
  }else{
      cout <<"No";
  }
  
  return 0;
}

Measured memory_bytes: 3588
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
//const ll mod = 998244353;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll N;cin>>N;
  vector<ll>A(N+1);
  for(int i=1;i<=N;i++)cin>>A[i];

  vector<ll>ans(N+1,0);
  for(int i=N;i>0;i--){
    ll num=0;
    ll index=i;
    ll j=1;
    while(index*j<=N){
      num+=ans[index*j];
      j++;
    }
    if(num%2!=A[i]%2)ans[i]=1;
  }
  vector<ll>v;
  for(int i=1;i<=N;i++){
    if(ans[i]==1)v.push_back(i);
  }

  cout<<v.size()<<endl;
  for(auto&&i:v)cout<<i<<" ";cout<<endl;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);cout<<fixed;
  cout<<setprecision(30);
  solve();
}


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

int main() {
  int N;
  cin>>N;
  
  if(0<=N && N<1200)
    cout<<"ABC"<<endl;
  else if(1200<=N && N<2800)
    cout<<"ARC"<<endl;
  else if(2800<=N)
    cout<<"AGC"<<endl;
}


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

int main(){

  int w, n, a, b;
  int x[30];
  char c;

  cin>>w>>n;

  for(int i=0;i<w;i++) x[i]=i+1;
  
  for(int i=0;i<n;i++){
    cin>>a>>c>>b;
    swap(x[a-1], x[b-1]);
  }

  for(int i=0;i<w;i++) cout<<x[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 3004
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c1 = sc.next();
    String c2 = sc.next();
    if(c1.charAt(2)==c2.charAt(0) && c1.charAt(0)==c2.charAt(2) && c1.charAt(1)==c2.charAt(1))
    System.out.println("YES");
    else
    System.out.println("NO");
    
	}
}

Measured memory_bytes: 22996
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

N,K=map(int,input().split())
x10 = N
x2 = Base_10_to_n(x10, K)
print(len(x2))

Measured memory_bytes: 3060
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int a[200010];

int main() {
  int n; cin>>n;
  REP(i,n) cin>>a[i];
  vector<int> b;
  REP(i,n) {
    if (i%2==0) {
      b.push_back(a[i]);
    } else {
      auto it = b.begin();
      it = b.insert(it, a[i]);
    }
  }
  if (n%2==1) {
    reverse(all(b));
  }
  REP(i,n) {
    cout << b[i] << " ";
  }
  cout << endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	ll N, D; cin >> N >> D;

	int ans = 0;
	REP(i,N){
		ll X, Y; cin >> X >> Y;
		double r = sqrt(X*X+Y*Y);
		if(r <= D) ans++;
	}

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 3652
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint n, k;
    cin >> n >> k;

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

    vector<lint> sum(n + 1);
    reps(i, n){
        sum[i] = (sum[i - 1] + a[i - 1]) % k;
    }

    lint ans = 0;
    unordered_map<lint, lint> mp;
    rep(i, n + 1){
        if(i >= k){
            --mp[((sum[i - k] - (i - k)) % k + k) % k];
        }
        ans += mp[((sum[i] - i) % k + k) % k];
        ++mp[((sum[i] - i) % k + k) % k];
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 11592
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	double a ,b ;
	cin>>a>>b;
	if(a>0 && b>0 && a<=10^100 && b<=10^100)
    {
      if(a>b)
    {
        cout<<" GREATER";
    }
    else if(a<b)
    {
        cout<<" LESS ";
    }
    else if(a==b)
    {
        cout<<" EQUAL  ";
    }
    }

}


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

int n;
long long int a[100005]={0};

long long int solve(bool even){
    long long int sum = 0, ans = 0;
    for(int i=0;i<n;++i){
        if(i == 0){
            long long int diff;
            if(even){
                diff = (a[i] > 0 ? 0 : 1 - a[i]);
            }else{
                diff = (a[i] < 0 ? 0 : -1 - a[i]);
            }
            sum += a[i] + diff;
            ans += abs(diff);
            continue;
        }else if(i > 0){
            long long int tmp = sum + a[i];
            if(tmp * sum < 0)sum = tmp;
            else{
                long long int diff = (-sum - (sum > 0 ? 1 : -1)) - a[i];
                sum = tmp + diff;
                ans += abs(diff);
            }
        }else sum += a[i];
    }

    return ans;
}

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

    long long int ans = min(solve(true), solve(false));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#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;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// https://atcoder.jp/contests/arc098/tasks/arc098_b
const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))

#define isBitSet(S, i) ((S >> i) & 1)

ll solve(vector<int>& v) {
    int l = 0;
    ll csum = 0;
    ll cxorsum = 0;
    int cnt = 0;
    ll ans = 0;
    for (int r = 0 ; r < v.size() ; r++)
    {
        csum += v[r];
        cxorsum ^= v[r];
        cnt++;
        while (csum!=cxorsum)
        {
            csum -= v[l];
            cxorsum ^= v[l];
            l++;
            cnt--;
        }
        ans += cnt;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int N; 
    cin >> N;
    vector<int> v;
    for (int i = 0 ; i < N; i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    cout << solve(v) << endl;
}

Measured memory_bytes: 4292
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    
    ll n, k;
    cin >> n >> k;
    ll  i = 0;
    while (true) {
        if (pow(k, i) > n) {
            cout << i;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 4004
#include "bits/stdc++.h"
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();
int mod = 1e9 + 7;

int boardPath(int sr, int sc, int er, int ec, vector<vector<char>> &board, vvi &dp)
{
    if (sr == er && sc == ec)
        return 1;
    if (dp[sr][sc] != 0)
        return dp[sr][sc];
    int count = 0;
    if (sc + 1 <= ec && board[sr][sc + 1] != '#')
        count = (count + boardPath(sr, sc + 1, er, ec, board, dp)) % mod;
    if (sr + 1 <= er && board[sr + 1][sc] != '#')
        count = (count + boardPath(sr + 1, sc, er, ec, board, dp)) % mod;
    return dp[sr][sc] = count % mod;
}

int boardPathDP(vector<vector<char>> &board, vvi &dp, int n, int m)
{
    dp[n][m] = 1;
    for (int i = m - 1; i >= 0; i--)
        dp[n][i] = board[n][i] == '#' ? 0 : dp[n][i + 1];

    for (int i = n - 1; i >= 0; i--)
        dp[i][m] = board[i][m] == '#' ? 0 : dp[i + 1][m];

    for (int i = n - 1; i >= 0; --i)
    {
        for (int j = m - 1; j >= 0; --j)
        {
            if (board[i][j] == '#')
                continue;
            dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
        }
    }

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

    return dp[0][0];
}

int solve()
{
    int n, m;
    cin >> n >> m;
    vector<vector<char>> board(n, vector<char>(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> board[i][j];

    vvi dp(n, vi(m, 0));
    // return boardPath(0, 0, n - 1, m - 1, board, dp);
    return boardPathDP(board, dp, n - 1, m - 1);
}

int main()
{
    cout << solve() << '\n';
    return 0;
}

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

int main(){
    int a[3][3];
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3) rep(k,3) if(a[j][k] == b) a[j][k] = 0;
    }
    rep(i,3){
        if(a[i][0] == a[i][1] && a[i][1] == a[i][2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(j,3){
        if(a[0][j] == a[1][j] && a[1][j] == a[2][j]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

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

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

    int64_t ans = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] >= x) {
            ans += a[i] - x;
            a[i] = x; 
        }
    }
    for (int i = 0; i < n - 1; i++) {
        int over = max(0, a[i] + a[i + 1] - x);
        ans += over;
        a[i + 1] -= over;
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
//情報オリンピック2011予選2「サッカー」
#include<stdio.h>

int main(void)
{
	int n, a, b, c, d, f1, f2, **teampoint;
	
	scanf("%d",&n);
	teampoint = new int *[n];
	
	for(f1 = 0; f1 < n; f1++){
		teampoint[f1] = new int [2];
		teampoint[f1][0] = 0;
	}
	
	for(f1 = 1; f1 <= n*(n-1)/2; f1++){
	
		scanf("%d %d %d %d",&a,&b,&c,&d);
		a--;b--;
		//対戦結果の勝ち点計算
		if(c > d)
			teampoint[a][0]+=3;
			
		else if(c < d)
			teampoint[b][0]+=3;
			
		else{
			teampoint[a][0]++;
			teampoint[b][0]++;
		}
		
	}
	//順位付け初期設定
	for(f1 = 0; f1 < n; f1++)
		teampoint[f1][1] = 1;
	//順位付け
	for(f1 = 0; f1 < n-1; f1++){
		for(f2 = f1+1; f2 < n; f2++){
			if(teampoint[f1][0] > teampoint[f2][0])
				teampoint[f2][1]++;
			else if(teampoint[f1][0] < teampoint[f2][0])
				teampoint[f1][1]++;
		}
	}
	
	for(f1 = 0; f1 < n; f1++)
		printf("%d\n",teampoint[f1][1]);
		
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int N,K;

int A[100],mn[100],mx[100];

int32_t main(){
	fast;
	cin>>N;
	FOR(i,1,N) cin>>A[i];
	
	int  mon = 1000;
	
	FOR(i,1,N-1){
		if (A[i+1] > A[i]){ //Sell
			mon += (A[i+1] - A[i]) * (mon / A[i]);
		}
	}
	cout<<mon;
}


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


int main(void){
    int a;
    cin >> a;
    
    string s;
    cin >> s;
     
    if (a >=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
    
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	bool odd = false;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(a % 2) {
			odd = true;
		}
	}
	cout << (odd ? "first" : "second") << endl;
		
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
  
public class Main{
  public static void main(String[] args){
    Scanner stdIn=new Scanner(System.in);
    int i=0,count=0;
    int a=stdIn.nextInt();
    char c=stdIn.next().charAt(0);
    int b=stdIn.nextInt();
    while (c!='?'){
	if (c=='+'){
	    System.out.println(a+b);
	}
	if (c=='-'){
	    System.out.println(a-b);
	}
	if (c=='*'){
	    System.out.println(a*b);
	}
	if (c=='/'){
	    System.out.println(a/b);
	}
	a=stdIn.nextInt();
	c=stdIn.next().charAt(0);
	b=stdIn.nextInt();
    }
  }
}



Measured memory_bytes: 26424
#include <atcoder/fenwicktree>
#include <cstdio>
 
using namespace std;
using namespace atcoder;
 
int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    fenwick_tree<long> t = fenwick_tree<long>(n);
    for (int i = 0; i < n; ++i) {
        long a;
        scanf("%ld", &a);
        t.add(i, a);
    }

    int f;
    for (int i = 0; i < q; ++i) {
        scanf("%d", &f);
        if (f == 1) {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%ld\n", t.sum(l, r));
        } else {
            int p;
            long x;
            scanf("%d %ld", &p, &x);
            t.add(p, x);
        }
    }
 
    return 0;
}


Measured memory_bytes: 8264
#include<stdio.h>

int r,c;
int senbei[10][10000],check[10];
long max;

long count(void){
	int i,j;
	char num;
	long ans=0;
	for(i=0;i<c;i++){
		num=0;
		for(j=0;j<r;j++){
			num+=senbei[j][i]^check[j];
		}
		if((int)num>(r/2)){
			ans+=(long)num;
		}else{
			ans+=(long)(r-(int)num);
		}
	}
	return ans;
}

void search(int i){
	if(i>=r){
		long stock;
		stock=count();
		max=(stock>max)?stock:max;
		return;
	}
	check[i]=1;
	search(i+1);
	check[i]=0;
	search(i+1);
}

int main(){
	int i,j;
	while(1){
		scanf("%d %d",&r,&c);
		if(r==0) break;
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				scanf("%d",&senbei[i][j]);
			}
		}
		max=0;
		search(0);
		printf("%ld\n",max);
	}
    return 0;
}

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

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

using namespace std;
using ll=long long;

const int INF = 100000;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
x,y = map(int,input().split())
if x + y == 2:
  print(1000000)
elif x + y == 3:
  print(500000)
elif x + y == 5:
  print(300000)
elif x + y == 4:
  print(400000)
elif x + y == 6:
  print(200000)
elif x + y >=5 and min(x,y) == 1:
  print(300000)
elif x + y >=5 and min(x,y) == 2:
  print(200000)
elif x + y >=5 and min(x,y) == 3:
  print(100000)
else:
  print(0)

Measured memory_bytes: 3064
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = list(range(1, n + 1))
ll = list(itertools.permutations(l, n))
if p == q:
    ans = 0
else:
    for i in ll:
        if i == p:
            p_n = ll.index(i) + 1
        elif i == q:
            q_n = ll.index(i) + 1
    ans = abs(p_n - q_n)
print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e4+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> e[MAXn];
ll c[MAXn];
ll idx,tt;
ll ans[MAXn];
void dfs(ll x,ll p){
    ans[x] = c[idx++];
    for (auto i:e[x]) {
        if (i == p) continue;
        dfs(i,x);
        tt += ans[i];
    }
}
int main(){
    IOS();
    ll n;
    cin >> n;
    REP (i,n-1) {
        ll a,b;
        cin >> a >> b;
        a--, b--;
        e[a].eb(b);
        e[b].eb(a);
    }
    REP (i,n) cin >> c[i];

    ll root = -1;
    pary(e,e+n);
    REP (i,n) if (SZ(e[i]) == 1) {
        root = i;
        break;
    }

    debug(root);
    sort(c,c+n,greater<ll>());
    dfs(root,root);

    cout << tt << endl;
    REP (i,n) cout << ans[i] << " \n"[i==n-1];
}


Measured memory_bytes: 1536
cnt = int(input())

nums = input().split()
calc_cnt = 0

n = sum(int(x) % 2 == 0 for x in nums)

while n == cnt:
    for i in range(cnt-1):
        nums[i] = int(nums[i]) / 2
    calc_cnt += 1
    n = sum(int(x) % 2 == 0 for x in nums)
print(calc_cnt)

Measured memory_bytes: 3060
from sys import stdin
import copy
N = int(stdin.readline().rstrip())
data = [None] * 5
for itr in range(0,5):
    data[itr] = int(stdin.readline().rstrip())
neck = 0
if N%min(data) != 0:
    neck = N/min(data) + 1
else:
    neck = N/min(data)
print(4+int(neck))

Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

typedef long long LL;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

const int MAX = 500000;
const int LIM = 100000000;
const LL MOD = 1000000007;
const int INF = 2147483647/2;
const LL LINF = 9223372036854775807/3;

int ucmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
int dcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a<*(int*)b?1:-1));}

int ucmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a>*(LL*)b?1:-1));}
int dcmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a<*(LL*)b?1:-1));}

void SORT(int*a, int n){qsort(a,n,sizeof(int),ucmpii);}
void SORTR(int*a, int n){qsort(a,n,sizeof(int),dcmpii);}
void LSORT(LL*a, int n){qsort(a,n,sizeof(LL),ucmpll);}
void LSORTR(LL*a, int n){qsort(a,n,sizeof(LL),dcmpll);}

int main(){
  char n[MAX];
  scanf("%s",n);

  int l = strlen(n);
  int sum = 0;

  REP(i,l){
    sum += n[i] - '0';
  }

  sum %= 9;

  if(!sum) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 1784
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


N = int(input())
A_input = list(map( int, input().split()))

j_sum = 0
for j in range(N):
        j_sum = j_sum + A_input[j]


sum = 0
for i in range(N - 1 ):
        j_sum = j_sum - A_input[i]
        sum = sum +  A_input[i] * j_sum

print(sum % (10**9 + 7) )

Measured memory_bytes: 31424
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,su=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {cin>>a[i];su^=a[i];}
    for(int i=0;i<n;i++){
        cout<<(su^a[i])<<"\n";
    }
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    ll N;
    cin >> N;
    vector<int> A(N);
    map<int, int> cnt;
    REP(i, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    //最大と最小を選んでなくす
    //最大で残せる数字
    sort(A.begin(), A.end());
    // print(A);
    ll res = 0;
    for(auto const &x : cnt) {
        res += x.second - 1;
    }
    if(res % 2 == 1) {
        cout << cnt.size() - 1 << endl;
    } else {
        cout << cnt.size() << endl;
    }
    return 0;
}

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

void fun(float a, float b, float c, float d, float e, float f)
{
    float u,v;
    v = (c*d-a*f)/(b*d-a*e);
    u = (c-b*v)/a;
    if (u>0 && v>0 && (u+v) <=1)
        cout <<"YES"<< endl;
    else
        cout <<"NO"<< endl;
}

int main()
{
    float x1,y1,x2,y2,x3,y3,xp,yp;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
    {
        if (x2-x1 != 0)
        {
            fun(x2-x1,x3-x1,xp-x1,y2-y1,y3-y1,yp-y1);
        }
        else
        {
            fun(x3-x1,x2-x1,xp-x1,y3-y1,y2-y1,yp-y1);
        }
    }
   return 0;
}

Measured memory_bytes: 1216
from collections import deque
def solve():
    K = int(input())
    q = deque(list(range(1,10)))
    cnt = 0

    tmp = 0
    while cnt < K:
        tmp = q.popleft()
        cnt += 1

        ones_place = tmp % 10
        if ones_place != 0:
            q.append(tmp*10+ones_place-1)
        q.append(tmp*10+ones_place)
        if ones_place != 9:
            q.append(tmp*10+ones_place+1)
    
    print(tmp)
        
if __name__ == '__main__':
    solve()

Measured memory_bytes: 11944
# E - ∙ (Bullet)
import sys
from collections import defaultdict
from math import gcd

readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())

# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。 
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)

'''
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)
'''

pow2_mod = [1] + [0] * (N + 10)
for i in range(1, N + 10):
    pow2_mod[i] = pow2_mod[i-1] * 2 % MOD

zeros = 0
for i in range(N):
    A, B = map(int, readline().split())
    # (0, 0)のイワシは他の全てのイワシと仲が悪いため、
    # 1匹のみでしか選ぶことができない。最後にこの数を足す。
    if A == 0 and B == 0:
        zeros += 1
    # (?, 0),(0, ?)のイワシは、?がどのような数字であろうとも
    # この組合せであれば仲が悪い。一律、(1,0)(0,-1)として考える。
    elif A == 0:
        d_S[(1, 0)] += 0
        d_T[(0, -1)] += 1
    elif B == 0:
        d_S[(1, 0)] += 1
        #d_T[(0, -1)] += 0
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        if A < 0:
            A *= -1
            B *= -1
        if A * B > 0:
            d_S[(A, B)] += 1
            #d_T[(B, -A)] += 0
        else:
            d_S[(-B, A)] += 0
            d_T[(A, B)] += 1

ans = 1
for (si, sj), s_cnt in d_S.items():
    t_cnt = d_T[(sj, -1*si)]
    tmp = 0
    tmp += pow2_mod[s_cnt] - 1 # Sから1匹以上選ぶ組合せ
    tmp += pow2_mod[t_cnt] - 1 # Tから1匹以上選ぶ組合せ
    tmp += 1 # どちらも選ばない組合せ
    ans = (ans * tmp)%MOD

ans -= 1 # 最終的に1匹も選ばない組合せ
ans += zeros # (0, 0)のイワシの数

print(ans%MOD)

Measured memory_bytes: 95936
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int B[] = new int[M];
        for(int i=0; i<M; i++) {
            B[i] = sc.nextInt();
        }
        int A[][] = new int[N][M];
        for(int s=0; s<N; s++) {
            for(int i=0; i<M; i++) {
                A[s][i] = sc.nextInt();
            }
        }
        int r = 0;
        for(int s=0; s<N; s++) {
            int score = C;
            for(int i=0; i<M; i++) {
                score += B[i] * A[s][i];
            }
            if(score>0) r++;
        }
        System.out.println(r);
   }
}

Measured memory_bytes: 24020
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
int tests(){ 
    int n;
    cin >> n;
    vector <int> a(n);
    int gcd = 0;
    forn(i,0,n){ 
        cin >> a[i];
        gcd = __gcd(gcd,a[i]);
    }
    if(gcd > 1)
        return cout << "not coprime\n",0;
    int mex = *max_element(all(a));
    vector <int> hash(mex+1);
    forn(i,0,n)
        hash[a[i]] = 1;
    bool ok = true;
    vector <bool> vis(mex+1,false);
    forn(i,2,mex+1)
        if(!vis[i]){  
            int collect = 0;
            for(int j = i ; j <= mex ; j += i)
            { 
                vis[j] = true;
                collect += hash[j] > 0;
            } 
            ok &= collect <= 1;
    }
    if(ok)
        return cout << "pairwise coprime\n",0;
    if(gcd == 1)
        return cout << "setwise coprime\n",0;
    cout << "not coprime\n";
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 11364