akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    string s, t;
    cin >> s;
    cin >> t;
    if (t.size() - s.size() == 1)
    {
        int flag = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] != t[i])
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
const int p[] = {1000000007, 1000000009, 1000000021, 1000000033};
const int c[] = {24809635, 839751792, 823818539, 210819658};

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

struct T {
    long long x[4] = {};
    int *a, n, i;
    T(int *a, int n) : a(a), n(n), i(0) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 4; j++)
                x[j] = ((long long)x[j] * c[j] + a[i]) % p[j];
        }
    }
    void shift() {
        for (int j = 0; j < 4; j++) {
            x[j] = (x[j] * c[j] + a[i] - modexp(c[j], n, p[j]) * a[i]) % p[j];
            if (x[j] < 0) x[j] += p[j];
        }
        i++;
    }
    bool operator==(const T &o) {
        for (int j = 0; j < 4; j++) if (x[j] != o.x[j]) return false;
        return true;
    }
};
int main() {
    int n; cin >> n;
    int a[n], b[n], c[n], d[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        c[i] = a[i]^a[(i+1)%n];
        d[i] = b[i]^b[(i+1)%n];
    }

    T h1(c, n), h2(d, n);
    for (int i = 0; i < n; i++) {
        if (h1 == h2) {
            cout << i << ' ' << (a[i]^b[0]) << endl;
        }
        h1.shift();
    }
}


Measured memory_bytes: 6528
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
         int n=in.nextInt();
         long a[]=new long[n];
         for(int i=0;i<n;i++){
            a[i]=in.nextLong();
         }
         long sum=0;
         for(int i=1;i<n;i++){
            if(a[i]<a[i-1]){
                sum=sum+a[i-1]-a[i];
                a[i]=a[i-1];
            }
         }
         System.out.println(sum);
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

}

Measured memory_bytes: 62736
fun main(args:Array<String>?): Unit {
    val q = readLine()!!.trim().toInt()
    repeat(q){
        val (c, a, n) = readLine()!!.trim().split(' ').map(String::toInt)
        val third = listOf(c, a, n).min()!!
        val first = listOf((c - third) / 2, a - third).min()!!
        val second = (c - third - first * 2) / 3
        println(first + second + third)
    }
}


Measured memory_bytes: 32816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    string s;
    cin>>s;
    deque<string> que;
    rep(i,s.size()) que.push_back(s.substr(i,1));
    int cnt=0;
    while(1){
    if (que.size()<=1) break;
    if (que.front()!=que.back()) {
        cnt++;
        que.pop_front();
        que.pop_back();
    }else{
        que.pop_front();
        que.pop_back();
    }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int c[27];
int s[366][27];
int t[366];
int last[27];

int main(void){
    int D;cin>>D;
    
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
    
    
    int v=0;
    for(int i=1;i<=D;i++){
        cin>>t[i];
        last[t[i]]=i;
        v+=s[i][t[i]];
        
        for(int j=1;j<=26;j++) v-=c[j]*(i-last[j]);
        //cout<<v<<endl;
    }
    
    int M;cin>>M;
    int d,q;
    for(int i=0;i<M;i++){
        v=0;
        fill(last,last+27,0);
        cin>>d>>q;
        t[d]=q;
        for(int j=1;j<=D;j++){
        last[t[j]]=j;
        v+=s[j][t[j]];
        
        for(int k=1;k<=26;k++) v-=c[k]*(j-last[k]);
        }
        cout<<v<<endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num),g/2));
  return power((num*num),g/2);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ld ans=0.0;
  int t;
  cin>>t;
  while(t--)
  {
    ld n;
    cin>>n;
    string s;
    cin>>s;
    if(s=="JPY")
      ans+=n;
    else ans+=n*380000.0;
  }
  cout<<fixed<<setprecision(8)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        String s = scan.next();
        scan.close();

        int ans = 0;
        boolean flagI = false;
        boolean flagJ = false;
        for (char i = '0'; i <= '9'; i++) {
            for (char j = '0'; j <= '9'; j++) {
                for (char k = '0'; k <= '9'; k++) {
                    for (int a = 0; a < n; a++) {
                        if (s.charAt(a) == i && !flagI) {
                            flagI = true;
                            continue;
                        }
                        if (s.charAt(a) == j && flagI && !flagJ) {
                            flagJ = true;
                            continue;
                        }
                        if (s.charAt(a) == k && flagI && flagJ) {
                            ans++;
                            break;
                        }
                    }
                    flagI = false;
                    flagJ = false;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 36884
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ll = unsigned long long int;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;

    vector<int> A(n);
    rep(i, n) cin >> A.at(i);

    int cnt = 0;
    while (true) {
        for (size_t i = 0; i < A.size(); i++) {
            if (A.at(i) % 2 == 0) {
                A.at(i) /= 2;
            } else {
                cout << cnt << endl;
                return 0;
            }
        }
        cnt++;
    }
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
typedef long long int LL;

int main()
{
	LL S; scanf("%lld", &S);
	LL d = sqrt(S);
	if (d != 1000000000) d++;
	LL D = d * d;
	LL R = D - S;
	LL x2 = 1, y1 = R;
	LL rr = sqrt(R);
	LL fac = 2;
	while (y1 >= 1000000000 && fac <= rr + 1)
	{
		if (y1 % fac == 0) y1 /= fac, x2 *= fac;
		else fac++;
	}
	printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, d, y1, x2, d);
	//printf("%lld\n", d * d - x2 * y1);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <unordered_map>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>

using namespace std;

bool isSubsequence(string s, string t);

int main() {

    string s;
    cin >> s;
    int arr[26] = {0};
    for(int i = 0;i<4;i++){
        arr[s[i] - 'A']++;
    }
    for(int i = 0;i<26;i++){
        if(arr[i] != 0 && arr[i] != 2){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
module Main where
import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad

rt3 = sqrt 3

data Point = Point Double Double deriving (Eq)
instance Show Point where
    show (Point x y) = show x ++ " " ++ show y

solve :: Int -> [Point]
solve = iter [(Point 0 0),(Point 100 0)] where
    iter pl 0 = pl
    iter pl n = iter (iter1 pl) (n-1)
    iter1 [p] = [p]
    iter1 (p@(Point px py):q@(Point qx qy):ps) = p:s:u:t:iter1 (q:ps) where
        s = Point (px*2/3 + qx/3) (py*2/3 + qy/3)
        t = Point (px/3 + qx*2/3) (py/3 + qy*2/3)
        u = Point (px/2 + qx/2 - rt3/6*qy + rt3/6*py) (rt3/6*qx - rt3/6*px + qy/2 + py/2) 

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

main :: IO() 
main = do
    n <- readIntLn
    let l = solve n
    mapM_ print l



Measured memory_bytes: 4216
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  vector<string> c(a);
  for(int i = 0;i < a;i++){
    cin >> c[i];
    cout << c[i] << endl << c[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
using namespace std;
int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    unordered_set<string>st;
    vector<string>substring;
    for(int i=0;i<s.size();i++)
    {
        for(int j=0;j<s.size();j++){
            string result="";
            if(j-i+1<=k)
            {
                for(int l=i;l<=j;l++)
                {
                    result+=s[l];
                }
                if(result=="")
                {
                    continue;
                }
                else
                {
                    if(st.find(result)==st.end()){
                        substring.push_back(result);
                        st.insert(result);
                    }
                }

            }
            
        }
    }
    sort(substring.begin(),substring.end());
    cout<<substring[k-1];
}

Measured memory_bytes: 4768
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApp8 { class Program { public static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]);decimal c=(int) a;decimal d = (int)b; Console.WriteLine("{0} {1} {2}",a/b,a%b,c/d); } } } 



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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int h,w;
int n;
int a;;

int c[100][100];

int main(){
  int now_i = 0,now_j=0;
  scanf("%d %d %d",&h,&w,&n);
  REP(i,n){
    int cnt = 0;
    scanf("%d",&a);
    while(cnt<a){
      if(now_j>=w){
        now_j = 0;
        now_i++;
      }
      c[now_i][now_j++] = i+1;
      cnt++;
    }
  }
  REP(i,h){
    REP(j,w){
      if(i%2){
        printf("%d ",c[i][j]);
      }else{
        printf("%d ",c[i][w-j-1]);
      }
    }
    printf("\n");
  }
}


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

int main() {
 int n;
 cin >> n;
 vector<int> vec(n-1);
 for(int i=0;i<vec.size();i++) {
   cin >> vec.at(i);
 }
  map<int, int> mp;
  for (int i=1;i<n+1;i++) {
   mp[i] = 0;
  }
  for(int i=0;i<vec.size();i++) {
    mp[vec.at(i)] += 1;
  }
  for(int i=1;i<n+1;i++) {
  cout << mp[i] << endl;
  }

  
 return 0;
}
  


Measured memory_bytes: 13488
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

typedef vector<int> vi;

bool comp(int a, int b){
  if (a % 10 == 0){
    if (b % 10 == 0){
      return true;
    }
    return false;
  }else if (b % 10 == 0){
    return true;
  }else{
    return a % 10 < b % 10;
  }
}

int main(){
  vi v(5);
  rep(i, 5) cin >> v[i];

  sort(v.begin(), v.end(), comp);

  int ans = v[0];
  rep(i, 5){
    if (i != 0){
      ans += v[i];
      if (v[i] % 10 != 0) {
        ans += 10 - (v[i] % 10);
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    int N, D, A;
    cin >> N >> D >> A;

   vector<pair<int, int>> p;
    for(int i=0; i<N; i++){
        int x, h;
        cin >> x >> h;
        p.push_back(make_pair(x, h));
    }

    sort(p.begin(), p.end());
    int H[N], X[N];
    for(int i=0; i<N; i++){
        X[i] = p[i].first;
        H[i] = p[i].second;
    }

    long sum[N+2];
    fill(sum, sum+N+2, 0);

    long ans = 0;
    for(int i=1; i<=N; i++){
        sum[i] += sum[i-1];

        int x = X[i-1];
        int h = H[i-1];

        if(h - sum[i]*A <= 0) continue;
        long add = ((h-sum[i]*A)-1)/A + 1;
        sum[i] += add;
        ans += add;

        int it = lower_bound(X, X+N, x + 2*D+1) - X;
        sum[it+1] -= add;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}


void solve(){

	int n,m;
	cin >> n >> m;
	vector <int> a(n);
	int sum = 0;
	rep0(i,n){
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	rep0(i,n) if((4*m*a[i])>=sum) cnt++;
	if(cnt>=m) cout << "Yes";
	else cout << "No";

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b,c,d,min;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a<b)
  {
    min=a;
  }
  else
  {
    min=b;
  }
  if(c<d)
  {
    min+=c;
  }
  else
  {
    min+=d;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
#define int ll

int dif=INF;
vi v(13,0);
vi sum(13,0);
int _find;
void   dfs(int value,int index,string ans){
    if(index>_find+1)return;
    //cout<<value<<endl;
    if(value==dif){reverse(all(ans));cout<<ans<<endl;return;}
    dfs(value,index+1,ans+"0");
    dfs(value-v[index],index+1,ans+"-");
    dfs(value+v[index],index+1,ans+"+");
    return;
}
signed main(){
    int w; cin>>w;
    rep(i,13)v[i]=sum[i]=(int)pow(3,i);
    rep(i,12)sum[i+1]+=sum[i];
    rep(i,13)if(w<sum[i]){_find=i;break;}
    //cout<<_find<<endl;
    dif=w;
    int value=0;int index=1;
    string s;
    dfs(value,index,s+"0");
    dfs(value-1,index,s+"-");
    dfs(value+1,index,s+"+");
}

Measured memory_bytes: 3384
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

Measured memory_bytes: 20596
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    const unsigned long long mod = 1E9+7;
    int N;
    cin >> N;
    unsigned long long A[N];
    unsigned long long sum = 0, out = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
        out += sum*A[i];
        out %= mod;
        sum += A[i];
        sum %= mod;
    }
    cout << out << endl;
}   

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define rg register

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}

const int N=101000,oo=0x3f3f3f3f;
struct Edge{int v,nxt;}a[N<<1];
int head[N],mi[N],mx[N],is[N],ki[N];
int n,m,_,died;

inline void cmin(int&A,int B){A=A<B?A:B;}
inline void cmax(int&A,int B){A=A>B?A:B;}

void dfs(int x,int las){
	mi[x]=-oo,mx[x]=+oo;
	if(~is[x])ki[x]=is[x]&1;
	else ki[x]=-1;
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v^las){
			dfs(a[i].v,x);
			cmax(mi[x],mi[a[i].v]-1);
			cmin(mx[x],mx[a[i].v]+1);
			if(ki[a[i].v]==-1)continue;
			if(ki[x]==-1)ki[x]=ki[a[i].v]^1;
			else if(ki[x]==ki[a[i].v]){died=1;return ;}
		}
	if(mi[x]>mx[x]){died=1;return ;}
	if(~is[x])
		if(mi[x]>is[x]||mx[x]<is[x]){died=1;return ;}
		else mx[x]=mi[x]=is[x];
}

void bfs(int x,int las){
	cmax(mi[x],mi[las]-1);
	cmin(mx[x],mx[las]+1);
	mx[x]=is[x]=mi[x];
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v^las)bfs(a[i].v,x);
}

void init();
int main(){
	init();dfs(1,0);
	if(died){puts("No");return 0;}
	if(mi[1]!=-oo)mi[0]=mi[1];
	else if(mx[1]!=+oo)mx[0]=mx[1];
	else mi[0]=0;
	bfs(1,0);puts("Yes");
	for(rg int i=1;i<=n;++i)
		printf("%d\n",is[i]);
	return 0;
}

void init(){
	memset(is,-1,sizeof is);
	read(n);int u,v,r;
	for(rg int i=1;i<n;++i){
		read(u),read(v);
		a[++_].v=v,a[_].nxt=head[u],head[u]=_;
		a[++_].v=u,a[_].nxt=head[v],head[v]=_;
	}read(u);while(u--)read(v),read(is[v]);
}

Measured memory_bytes: 9088
#include<stdio.h>


int main(void){

  int i, j, k;
  int h[10], max;


  for(i=0; i<10; ++i){
    scanf("%d", &h[i]);
  }
 
  for(i=0; i<10; ++i){
    max = h[i];
    k=i;
    for(j=i+1; j<10; ++j){
      if(max<h[j]){
	max=h[j];
	k=j;
      }
    }
    h[k]=h[i];
    h[i]=max;
  }

  printf("%d\n%d\n%d\n", h[0], h[1], h[2]);
  return(0);
}



Measured memory_bytes: 2040
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

int check[1000][4];
char p[301];

int main(){
	int a, b, c, n;

	while (scanf("%d%d%d", &a, &b, &c), a){
		fill(p, p + 301, 2);
		scanf("%d", &n);

		for (int i = 0; i < n; i++){
			for (int j = 0; j < 4; j++)
				scanf("%d", &check[i][j]);
			if (check[i][3]){
				for (int k = 0; k < 3; k++)
					p[check[i][k]] = 1;
			}
		}

		for (int i = 0; i < n; i++){
			if (!check[i][3]){
				pair<int, int> P(0, 0);
				for (int j = 0; j < 3; j++){
					if (p[check[i][j]] == 1){
						P.first++;
						P.second += j;
					}
				}
				if (P.first == 2)
					p[check[i][3 - P.second]] = 0;
			}
		}

		for (int i = 1; i <= a + b + c; i++)
			printf("%d\n", p[i]);
	}

	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    cout << round((a+b)/2.0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (A[i] == A[j] || A[j] == A[k] || A[k] == A[i]) continue;
				vector<int> v{A[i], A[j], A[k]};
				sort(all(v));
				if (v[0] + v[1] > v[2]) {
					c++;
				}
			}
		}
	}
	cout << c;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,p;
  cin >> n >> p;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1){
      cout << (long long)pow(2,n-1);
      return 0;
    }
  }
  if(p==0)cout << (long long)pow(2,n);
  else cout << 0;
}


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

int main(void){
    int i,j,k;
    int a,b,c,answer;
    
    scanf("%d %d %d",&a,&b,&c);
   
    answer = c - (a - b);
    if(answer < 0){
        answer = 0;
    }
    
    printf("%d\n",answer);
    
    return 0;
}



Measured memory_bytes: 256
S = input()

rlt = 0
b = ''
tA = 0
A = 0
BC = 0
for s in S:
  if s == 'A':
    if b == 'A':
      tA += 1
    elif b == 'B':
      rlt += A*BC
      tA = 1
      A = 0
      BC = 0
    else:
      rlt += A*BC
      tA = A + 1
      A = 0
      BC = 0
  elif s == 'B':
    if b == 'B':
      rlt += A*BC
      tA = 0
      A = 0
      BC = 0
  elif s == 'C':
    if b == 'B':
      A += tA
      tA = 0
      BC += 1
    else:
      rlt += A*BC
      tA = 0
      A = 0
      BC = 0
  b = s

rlt += A*BC
  
print(rlt)

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int minab = min(a,b);
    int maxab = max(a,b);
    if(minab < c && c < maxab){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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

int n, a[100005];
int main() {
	int i, d;
	cin>>n;
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	for(i=n-1; i>=1; i--) {
		d = a[i] - a[i+1];
		if(d>1) {cout<<"No"; return 0;}
		else if(d==1) a[i]--;
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 640
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

A,B=rl()

c_a = A//100 - 100 + 1
c_b = B//100 - 100 + 1
if A > (A//100*100 + A//10000 + (A//1000-A//10000*10)*10):
    c_a += 1
if B >= (B//100*100 + B//10000 + (B//1000-B//10000*10)*10):
    c_b += 1

print(c_b-c_a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll sm1 = 0;
    ll sm2 = 0;
    ll res1 = 0;
    ll res2 = 0;
    rep(i, n) {
        sm1 += a[i];
        sm2 += a[i];
        if (i % 2 == 0) {
            if (sm1 <= 0) {
                res1 += -sm1 + 1;
                sm1 = 1;
            }
            if (sm2 >= 0) {
                res2 += sm2 + 1;
                sm2 = -1;
            }
        } else {
            if (sm1 >= 0) {
                res1 += sm1 + 1;
                sm1 = -1;
            }
            if (sm2 <= 0) {
                res2 += -sm2 + 1;
                sm2 = 1;
            }
        }
    }
    cout << min(res1, res2) << endl;
}

Measured memory_bytes: 1024
def gcd(a,b):
    #print(a)
    #print(b)
    if b==0:
        return a
    #a=a%b
    #b=a
    return gcd(b,a%b)

N=int(input())
x=1
for i in range(N):
    t=int(input())
    x=(x*t)//gcd(x,t)
print(x)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] a = new int [N];
		long sumh = 0;
		long[] sum = new long [N];
		for (int i=0; i < N; i++) {
    		a[i] = stdIn.nextInt();
    		sum[i] = sumh + a[i];
    		sumh += a[i];
    	}
		long min = Math.abs(sum[0]*2 - sumh);
		for (int i=1; i < N-1; i++) {
			if (Math.abs(sum[i]*2 - sumh) < min) {
				min = Math.abs(sum[i]*2 - sumh);
			}
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 85576
import collections

####入力
H,W = map(int,input().split())
#gridの定義
grid = []
flat_grid = []
for i in range(H):
  S = input()
  tasu = [S[i] for i in range(W) ]
  grid.append(tasu )
  flat_grid = flat_grid + tasu
####入力終了

sx,sy = 0,0
gx,gy = W-1,H-1

#seenとtodoの初期設定
l_seen = [[False for i in range(W)] for j in range(H) ]
l_todo = []
dist = [[0 for i in range(W)] for j in range(H) ]

#seenに出発地点を決めてやる、今回は[0][0]である
l_seen[sy][sx] = True 

#pに隣接する頂点４つについて初期設定
for i in [[sx+1,sy],[sx,sy+1],[sx-1,sy],[sx,sy-1] ]:
  #場外アウトしたり、移動先が壁の場合はスルー
  if (i[0]<0 or i[1] <0 or i[1]>=H or i[0] >= W ):
    continue
  #移動先が壁の場合スルー
  if grid[i[1]][i[0]] == "#":
    continue  
  dist[i[1]][i[0]] = 1 
  #pに隣接する頂点を探索済みにする
  l_seen[i[1]][i[0]] = True 
  #pに隣接する頂点をtodoリストに追加
  l_todo = l_todo + [i]


#探索
while len(l_todo) != 0:

  #幅優先探索 todoリストから次のターゲットを取り出す
  v = l_todo.pop(0) 

  for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
    #場外アウトしたり、移動先が壁の場合はスルー
    if (i[0]<0 or i[1] <0 or i[1]>=H or i[0] >= W ):
      continue
    #移動先が壁の場合スルー
    if grid[i[1]][i[0]] == "#":
      continue
    #移動先が探索済みの場合スルー
    if l_seen[i[1]][i[0]] == True:
      continue  

    if l_seen[i[1]][i[0]] == False:
      l_seen[i[1]][i[0]] = True
      l_todo = l_todo + [i]
      dist[i[1]][i[0]]=dist[v[1]][v[0]]+1

d = dist[gy][gx]
w_num = collections.Counter(flat_grid)["."]
if d == False:
  print(-1)
else:
  print(w_num -(d+1)) #d+1はスタート地点からゴールまでのますの数

Measured memory_bytes: 41968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    n%=1000;
    n=1000-n;
    if(n==1000) cout<<0<<endl;
    else cout<<n<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


int main(){
    ll n, k;
    cin >> n >> k;

    double res = 0;
    for(int i = 1; i <= n; i++){
        double prob = (1.0 / double(n));
        int t = i;
        while(t < k){
            t *= 2;
            prob /= 2.0;
        }
        res += prob;
    }

    printf("%.10f\n", res);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class...T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int mid = 5e8, stride = 2e4 + 5;
    int N;
    cin >> N;
    vector<int> p_inv(N), A(N), B(N);
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        p_inv[p - 1] = i;
    }
    for (int i = 0; i < N; i++) {
        A[i] = mid - stride * (N - i) + p_inv[i];
        B[i] = mid + stride * (N - i) + p_inv[i];
    }
    cout << A << endl;
    cout << B << endl;
}

Measured memory_bytes: 896
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	let d = v[3];
	if a+b > c+d {
		println!("Left");
	}else if a+b < c+d {
		println!("Right");
	}else{
		println!("Balanced");
	}
}

Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        int c = Integer.parseInt(scanner.nextLine());
        int d = Integer.parseInt(scanner.nextLine());
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll tot = 0;
  
  rep(i,n){
    auto upper = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    auto lower = lower_bound(a.begin(),a.end(),b[i])-a.begin();
    tot += upper*lower;

  }
  cout << tot << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<long> l(87);
  int n,i;
  l.at(0)=2LL;
  l.at(1)=1LL;
  for(i=2;i<(int)l.size();i++) l.at(i)=l.at(i-2)+l.at(i-1);
  cin>>n;
  cout<<l.at(n)<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = input()
WORD = "keyence"

if S == WORD:
    print("YES")
    exit()

for s in range(len(S)):
    for e in range(s,len(S)+1):
        a = S[:s]
        sub = S[s:e]
        b = S[e:]
        # print(a)
        # print(sub)
        # print(b)
        if a+b == WORD:
            print("YES")
            exit()

print("NO")


Measured memory_bytes: 3060
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}



Measured memory_bytes: 2640
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n,a;
  cin >> n >> a;
  n = n%500;
  if(n <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
digits = [0]*40
for i in a:
    for j in range(40):
        digits[j] += i>>j&1
ans = 0
flg = True
for i in range(39, -1, -1):
    if flg and k>>i&1==0:
        ans += digits[i]*2**i
        continue
    ans += max(digits[i], n-digits[i])*2**i
    if flg and digits[i]>=(n+1)//2:
        flg = False
print(ans)

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int k = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}


Measured memory_bytes: 32624
from collections import deque
n = int(input())
tree = [[] for _ in range(n)]
edge = []

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    edge.append((a, b))


# serch max number of color
for i in range(n):
    if i == 0:
        color = len(tree[i])
    else:
        color = max(color, len(tree[i])+1)

upper = [0 for _ in range(n)]

for i in range(n):
    if not tree[i]:
        continue

    top = upper[i]
    tmp = tree[i].copy()
    cnt = 1
    while tmp:
        if cnt == top:
            cnt += 1
        upper[tmp.pop()] = cnt
        cnt += 1

ans = []
for x, y in edge:
    ans.append(upper[y])
print(color)
print(*ans, sep="\n")


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, m;
PII a[N];
priority_queue<int> heap;

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%d%d", &a[i].F, &a[i].S);
	sort(a, a + n);
	
	// for (int i = 0; i < n; i ++ ) cout << a[i].F << ' ' << a[i].S << endl;
	
	LL res = 0;
	for (int cur = m - 1, i = 0; cur >= 0; cur -- )
	{
		while (i < n && a[i].F + cur == m)
		{
			heap.push(a[i].S);
			i ++ ;
		}
		if (heap.size())
		{
			res += heap.top();
			heap.pop();
		}
	}
	printf("%lld\n", res);
    return 0;
}


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

int main(void){
int k;
char s[200];
scanf("%d %s",&k,s);
if(strlen(s)<=k){printf("%s",s);}
else{for(int i=0;i<k;i++){
    printf("%c",s[i]);
}
printf("...");

}
}


Measured memory_bytes: 1732
/*
    Author:zeke

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

int main(){
    ll n;
    cin>>n;
    V vec(n);
    rep3(i,1,n+1){
        ll temp=i;
        while(temp<=n){
            vec[temp]++;
            temp+=i;
        }
    }
    ll res=0;
    rep3(i,1,n+1){
        res+=i*vec[i];
    }
    cout<<res<<endl;

}

Measured memory_bytes: 81344
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{


    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        char[] letter = str.ToArray();
        string input = Console.ReadLine();
        char[] inputletter = input.ToArray();

        var index = new List<int>();

        for(int i = 0; i < letter.Length; i++)
        {
            if(inputletter[0] == letter[i])
            {
                index.Add(i);
            }
        }

        bool judge = false;

        for (int i = 0; i < index.Count; i++)
        {
            int j;
            int k;
            for (j = index[i], k = 0; k < inputletter.Length; j++, k++)
            {
                
                
                if(inputletter[k] != letter[j])
                {              
                    break;
                }
                if (j == letter.Length - 1)
                {
                    j = -1;
                }
               
            }
            if(k == inputletter.Length)
            {
                judge = true;
                break;
            }
            else
            {
                judge = false;
            }

        }

        if (judge)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }


        
    }
}


Measured memory_bytes: 18228
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	int r, d, x;
	cin >> r >> d >> x;
	for(int i = 0; i < 10; i++){
		x = r*x-d;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N,M,K;cin >> N >> M >> K;
    vector<LL> A(N);
    vector<LL> B(M);
    rep(i,N)cin >> A[i];
    rep(i,M)cin >> B[i];

    
    vector<LL> Arui(N+1);
    vector<LL> Brui(M+1);
    Arui[0] = 0;
    Brui[0] = 0;
    
    rep(i,N){
        Arui[i+1] = Arui[i] + A[i];
    }
    rep(i,M){
        Brui[i+1] = Brui[i] + B[i];
    }
    
    LL ans = 0;
    
    rep(i,N+1){
        LL tmp = 0;
        LL lim = K - Arui[i];
        if(lim < 0)continue;
        tmp = i;
        LL lb = 0;
        LL ub = M+1;
        while(ub - lb > 1){
            LL mid = (ub+lb)/2;
            LL tm = Arui[i] + Brui[mid];
            if(tm <= K){
                lb = mid;
            }
            else{
                ub = mid;
            }
        }
        tmp += lb;
        ans = max(ans,tmp);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 9580
n, m, x, y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_list.append(x)
y_list.append(y)

print("No War" if min(y_list) - max(x_list) >= 1 else "War")


Measured memory_bytes: 3060
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
    int n,k;
    cin>>n>>k;
    int ara[n];
    for(int i=0; i<n; i++)cin>>ara[i];
    int sum=0;
    sort(ara,ara+n);
    for(int i=0; i<k; i++){
        sum+=ara[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int> (m));
    REP(i,m){
        cin >> b.at(i);
    }
    int sum = 0;
    int ans = 0;
    REP(i,n){
        sum = 0;
        REP(j,m){
            cin >> a.at(i).at(j);
            sum += a.at(i).at(j) * b.at(j);
        }
        if(sum + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import collections, itertools
N = int(input())
mod = 10**9 + 7
dp = collections.defaultdict(int)
dp['TTTA'] = dp['TTTG'] = dp['TTTC'] = dp['TTTT'] = 1
for _ in range(N - 1):
    dp2 = collections.defaultdict(int)
    for p, q, r, s, t in itertools.product('AGCT', repeat=5):
        if 'AGC' in [q + s + t, s + r + t, r + s + t, q + r + t, r + t + s]:
            continue
        else:
            dp2[q + r + s + t] += dp[p + q + r + s] % mod
    dp = dp2
print(sum(dp.values()) % mod)


Measured memory_bytes: 9372
sa = str(input())
sb = str(input())
sc = str(input())
d = {'a': [sa, len(sa), 0], 'b': [sb, len(sb), 0], 'c': [sc,len(sc), 0]}
x = 'a'
while True:
    if d[x][1] == d[x][2]:
        break
    d[x][2] += 1
    x = d[x][0][d[x][2]-1]
print(x.upper())


Measured memory_bytes: 3064