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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vl L(n);
    rep(i,n)cin>>L[i];
    sort(all(L));
    ll res=0;
    rep(i,n-2){
        rep2(j,i+1,n-1){
            rep2(k,j+1,n){
                if(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){
                    if(L[i]!=L[j]&&L[k]!=L[j]&&L[i]!=L[k])res++;
                }
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3660
def main():
    n, m, *ab = map(int, open(0).read().split())
    e = [[] for _ in range(n)]
    for u, v in zip(*[iter(ab)] * 2):
        e[u - 1].append(v - 1)
        e[v - 1].append(u - 1)

    ans = 0
    for _ in range(m):
        count = 0
        for i, x in enumerate(e):
            if len(x) == 1:
                e[i] = []
                e[x[0]].remove(i)
                count += 1
        if count:
            ans += count
        else:
            break

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b)cout<<"a < b"<<endl;
	else if(a>b)cout<<"a > b"<<endl;
	else if(a==b)cout<<"a == b"<<endl;
	
	return 0;
}

//ｍじゅれい７いくご；い８ぁs家hwfぇkj声rj下rg毛f：絵jgぺロgj」ぐぇい王gふぉ；w４ちぃぺhygfpリオwhごうぇりhy魏ぺrh魏prhjごprhj五ぺjf歩絵hpgふぉうえぽgじぇおpfjうぇおjごうぇjごrj声rjごうぇjg＠pjwpg「尾wrjk「ぽgjをpjgw露pj後wjg路pウェrjg歩w所pr後pウェj後prwjkぽgjrpをjg歩wj歩rjgぽwrjとdr子gfk度pk後pdk後pdkgpkwrgkw「尾prkgp「wrkg「尾pwkr「pgkw「ぽrg所pwjg「pwrjg「pwjg「ぽj「尾wgjw「おgjをgj「尾pgj


Measured memory_bytes: 3068
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    string N;
    cin >> N;
    cout << (N[0] == N[2] ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
    int h,w;
    while(1){
        scanf("%d %d", &h , &w);
        if(h == 0 && w == 0){
            break;
        }
        
        for(int i = 0; i < h; i++){
            if(i == 0 || i == h - 1){
                for(int j = 0; j < w; j++){
                    printf("#");
                }
            }else{
                for(int j = 0; j < w; j++){
                    if(j == 0 || j == w - 1){
                        printf("#");    
                    }else{
                        printf(".");    
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2688
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if( (n|m) == 0) break;
			int p[] = new int[n+1];
			p[0] = 0;
			for(int i=1;i<=n;i++) p[i] = sc.nextInt();
			int num[] = new int[(n+1)*(n+1)];
			
			int size = 0;
			for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) {
				if( p[i] + p[j] <= m )
					num[ size++ ] = p[i]+p[j];
			}
			sort(num);
//			debug(num);
			int max = 0;
			for(int i=0;i<(n+1) * (n+1);i++) {
				int lim = m - num[i];
				int left = 0;
				int right = size;
				while(left < right) {
					int c = ( left + right ) / 2;
					if( lim > num[c] ) {
						left = c+1;
					}
					else if( lim < num[c] ) {
						right = c;
					}
					else {
						break;
					}
				}
//				debug(num[i], right-1, num[right-1]);
				max = max(max, num[i] + num[right-1]);
			}
			System.out.println(max);
			
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

s = 0
x = 0
j = 0

ans = 0
for i in range(n):
    while j < n:
        if s + A[j] == x ^ A[j]:
            s += A[j]
            x ^= A[j]
            j += 1
        else:
            break
    ans += j - i 
    s -= A[i]
    x ^= A[i]
print(ans)


Measured memory_bytes: 77900
#include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;

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

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


    vector<int> f(n, 0);
    for (int i=0; i<n; i++) {
        for (int j=0; j<10; j++) {
            int fi; cin >> fi;
            f[i] |= fi<<j;
        }
    }


    vector<vector<int>> p(n, vector<int>(11));
    for (int i=0; i<n; i++) {
        for (int j=0; j<=10; j++) {
            cin >> p[i][j];
        }
    }


    int64 ans = INT_MIN;
    for (int i=1; i<(1<<10); i++) {
        int64 cnt = 0;
        for (int j=0; j<n; j++) {
            int c = __builtin_popcount(i & f[j]);
            cnt += p[j][c];
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

x = input()
y = input()
a = []
b = []
for i in range(len(x)):
    a.append(x[i])
for i in range(len(y)):
    b.append(y[i])
a.sort()
b.sort(reverse=True)
j(''.join(a) < ''.join(b))

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

using namespace std;

int numDiv(int n) {
    int ret = 0;
    for (int i = 1; i <= n; ++i) {
        if (n % i == 0) {
            ++ret;
        }
    }
    return ret;
}

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

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 == 1 && 8 == numDiv(i)) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<a){
		cout<<a-k<<" "<<b;
	}
	else if(k>=a && k<=a+b)
		cout<<0<<" "<<b-(k-a);
	else
		cout<<"0 0";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

void updatemax(ll& a, ll b) { if (b > a) a = b; }

ll dp[3002][3002]{};
int main() {
    string s,t,ans;
    cin >> s >> t;
    rep(i,s.size()) rep(j,t.size()) {
        auto& e = dp[i+1][j+1];
        if (s[i] == t[j]) {
            updatemax(e, dp[i][j]+1);
        }
        updatemax(e, dp[i+1][j]);
        updatemax(e, dp[i][j+1]);
    }

    ll i = s.size();
    ll j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j-1]) {
            --j;
        } else {
            --i;
            --j;
            ans.push_back(s[i]);
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  
  if(S.length() <= K)
    cout << S << endl;
  else{
    for(int i=0; i<K; i++)
      cout << S.at(i);
    cout << "..." << endl;
  }
    
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>

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

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if(abs(a-c) <= d)
        printf("Yes\n");
    else if(abs(a-b) <= d && abs(b-c) <= d)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
import sys

N, K = map(int, input().split())
d = list(map(int, input().split()))

for i in range(N, 10 ** 7):
    ansb = True
    for j in d:
        if str(i).count(str(j)) != 0:
            ansb = False
            break
    if ansb:
        print(i)
        sys.exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
char s[MAXN];
int main()
{
    scanf("%s",s+1);
    int n = strlen(s+1);
    for(int i = 1 ; i <= n; i++){
        if(i % 2 == 1) printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const int MAXN =101000;

int n;
int a[ MAXN ];
bool f[ MAXN ];

int main(){
    read(n);
    for (int i=1;i<=n;i++)
        read(a[i]);
    f[0]=1;
    for (int i=1;i<=n;i++)
        for (int j=MAXN-1;j>=a[i];j--)
            f[j]=f[j]||f[j-a[i]];
    for (int i=MAXN-1;i>=0;i--)
        if ( (f[i]) && ( i%10!=0) )
            {
                printf("%d\n",i);
                return 0;
            }
    puts("0");
    return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, p;
    cin >> a >> p;
    cout << (a*3 + p) / 2 << "\n";
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size() - 1; ++i){
    if (s[i] == s[i + 1]) {
      cout<< "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ABC145C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var xcords = new int[N];
            var ycords = new int[N];
            var lengths = new double[Factorial(N)];
            var src = new int[N];
            for (int i = 0; i < N; i++)
            {
                src[i] = i;
            }

            var perm = Permutation<int>.All(src);

            for (int i = 0; i < N; i++)
            {
                var coordinates = Console.ReadLine().Split(' ');
                xcords[i] = int.Parse(coordinates[0]);
                ycords[i] = int.Parse(coordinates[1]);
            }

            for (int i = 0; i < Factorial(N); i++)
            {
                var dist = 0.0;
                for (int j = 0; j < N - 1; j++)
                {
                    dist += Length(xcords[perm.ElementAt(i)[j]], ycords[perm.ElementAt(i)[j]],
                        xcords[perm.ElementAt(i)[j + 1]], ycords[perm.ElementAt(i)[j + 1]]);
                }

                lengths[i] = dist;
            }

            Console.WriteLine("{0}", lengths.Average());
            Console.ReadLine();
        }

        public static long Factorial (int n)
        {
            if (n == 0)
                return 1L;
            return n * Factorial (n - 1);
        }

        public static double Length(int xi, int yi, int xj, int yj)
        {
            double d = Math.Sqrt(Math.Pow((double)xj - (double)xi, 2) + Math.Pow((double)yj - (double)yi, 2));
            return d;
        }

        static class Permutation<T>
        {
            private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
            {
                var N = a.Length;
                if (N == 0)
                {
                    perms.Add(stack.Reverse().ToArray());
                }
                else
                {
                    var b = new T[N - 1];
                    Array.Copy(a, 1, b, 0, N - 1);
                    for (int i = 0; i < a.Length; i++)
                    {
                        stack.Push(a[i]);
                        Search(perms, stack, b);
                        if (i < b.Length)
                        {
                            b[i] = a[i];
                        }

                        stack.Pop();
                    }
                }
            }

            public static IEnumerable<T[]> All(IEnumerable<T> src)
            {
                var perms = new List<T[]>();
                Search(perms, new Stack<T>(), src.ToArray());
                return perms;
            }

        }
    }
}


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

int main(void){
  int n;
  long long ans = 0;
  cin >> n;
  vector<string> strings(n);
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    sort(s.begin(), s.end());
    strings[i] = s;
  }
  sort(strings.begin(), strings.end());

  long long same = 1;
  for(int i = 0; i < n; i++){
    if(i != n-1 && strings[i] == strings[i+1]) same++;
    else{
      ans += same*(same+1)/2 - same;
      same = 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}

  



void solve(){
  
  int n;
  cin>>n;
  set<int> ar;
  int a;
  map<int,int> m;
  loop(i,n){
    cin>>a;
    m[a]++;
    ar.insert(a);
  }
  vi arr(all(ar));
  n=sz(ar);
  //cout<<n;
  int ans=0;
  fr(i,0,n-3){
    fr(j,i+1,n-2){
      fr(k,j+1,n-1){
        if(arr[i]+arr[j]>arr[k]){
          ans+=m[arr[i]]*m[arr[j]]*m[arr[k]];
        }
      }
    }
  }
  cout<<ans;

}




signed main()   
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif  

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



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

int main() {
  string s;
  cin >> s;
  bool cflg = false;
  for(int i = 0; i < s.size(); i++){
    if(cflg){
      if(s[i] == 'F'){
        cout << "Yes";
        return 0;
      }
    }else{
      if(s[i] == 'C') cflg = true;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<long long int>dp(M + 1);
	dp[0] = power(2, N, MOD);
	for (auto i : v) {
		for (int j = M; j >= i; j--) {
			dp[j] += dp[j - i] * power(2, MOD - 2, MOD);
			dp[j] %= MOD;
		}
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 3696
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

  rep(i,n-1) {
    int t = 0;
    rep(j,n-i-1) {
      if (t < s[i+j]) {
        t = s[i+j];
      } else if (t%f[i+j] == 0) {
        ;
      } else {
        t += f[i+j] - (t%f[i+j]);
      }
      t += c[i+j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 3604
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_point_on_line(point a, point b, point c) {
  return cross(a-c, b-c)==0 && dot(a-c, b-c)<=0;
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

int inside(point p, vector<point> ps, int n){
  point a,b;
  a=b=p;
  b.x=DBL_MAX;
  ps.push_back(ps[0]);
  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<n;i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;
  
  for(int i=0;i<n;i++){
    if(is_point_on_line(ps[i],ps[i+1],p))return 1;
  }

  int cnt1=0;
  for(int i=0;i<n;i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;

  int cnt=0;
  for(int i=0;i<n;i++)
    if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;

  return (cnt-cnt1)%2;
}

int crossPol(vector<point> pol1, vector<point> pol2){
  int szpol1=pol1.size();
  int szpol2=pol2.size();

  for(int i=0;i<szpol1;i++)
      if(inside(pol1[i],pol2,szpol2))return 1;

  for(int i=0;i<szpol2;i++)
    if(inside(pol2[i],pol1,szpol1))return 1;

  pol1.push_back(pol1[0]);
  pol2.push_back(pol2[0]);

  for(int i=0;i<szpol1;i++)
    for(int j=0;j<szpol2;j++)
      if(is_intersected_ls(pol1[i],pol1[i+1],pol2[j],pol2[j+1]))return 1;
  
  return 0;
}

int gr[101][101],fg[101],m;

void dfs(int j){
  fg[j]=1;
  for(int k=0;k<m;k++)
    if(gr[j][k]==1 && !fg[k])dfs(k);  
}

int main(void){
  int n;
  point a;
  vector<point>pol[101];

  while(cin >> n,n){

    for(int i=0;i<n;i++){
      cin >> m;
      
      for(int i=0;i<101;i++)pol[i].clear();

      for(int i=0;i<101;i++){
	for(int j=0;j<101;j++){
	  gr[i][j]=0;
	}
	fg[i]=0;
      }

      for(int j=0;j<m;j++){
	for(int k=0;k<4;k++){
	  cin >> a.x >> a.y;
	  pol[j].push_back(a);
	}
      }

      for(int j=0;j<m;j++){
	for(int k=0;k<m;k++){
	  if(j!=k && crossPol(pol[j],pol[k]))gr[j][k]=gr[k][j]=1;
	}
      }

      int cnt=0;
      for(int j=0;j<m;j++){
	if(fg[j]==0){
	  dfs(j);
	  cnt++;
	}
      }

      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int R, G, B, N;

    cin >> R >> G >> B >> N;

    int cnt = 0;
    for (int i = 0; i <= N; i += R) {
        for (int j = 0; j <= N - i; j += G) {
            if ((N - i - j) % B == 0) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if len(bn)>3:
        print("No")
    elif len(bn)==1:
        if bn[0]==0:
            print("Yes")
        else:
            print("No")
    elif len(bn)==2:
        if an.count(0)==(N/3):
            print("Yes")
        else:
            print("No")
    elif bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)!=(N/3):
                print("No")
                break
        else:
            print("Yes")

Measured memory_bytes: 15220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    string N;
    cin >> N;
    
    rep(i, 3)
    {
       if(N[i]=='7')
       {
           cout << "Yes" << endl;
           return 0;
       }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[101][4][4][4];

int main(){
  int n; cin >> n;
  dp[0][3][3][3]=1;
  rep(len,n){
    rep(i,4){
      rep(j,4){
        rep(k,4){
          rep(l,4){
            if(j==0&&k==1&&l==2) continue;
            if(i==0&&k==1&&l==2) continue;
            if(i==0&&j==1&&l==2) continue;
            if(j==1&&k==0&&l==2) continue;
            if(j==0&&k==2&&l==1) continue;
            dp[len+1][j][k][l]+=dp[len][i][j][k];
            dp[len+1][j][k][l]%=mod;
          }
        }
      }
    }
  }
  ll ans=0;
  rep(j,4)rep(k,4)rep(l,4){
    ans+=dp[n][j][k][l];
    ans%=mod;
  }
  cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll vis[666666];
int const M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll t,a;
    cin >> t >> a;
    double h[n],x[n];
    double res,mini=inf;
    for(ll i=0; i<n; i++){
        cin >> h[i];
        x[i]=t-0.006*h[i];
        if(abs(a-x[i])<=mini){
            mini=abs(a-x[i]);
            res=i+1;
        }
    }
    cout << res;
    return 0;
}
/* The judge is never wrong! Your code is buggy ðŸ˜ˆ
   Look for:
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var S = ReadLine();
        var A = new int[N + 1];
        var B = new int[N + 1];
        var C = new int[N + 1];
        var D = new int[N + 1];

        for (int i = 0; i < N; i++)
        {
            if (S[i] == 'E')
            {
                A[i + 1] = A[i] + 1;
                B[i + 1] = B[i];
            }
            else
            {
                A[i + 1] = A[i];
                B[i + 1] = B[i] + 1;
            }
            int u = N - i - 1;
            if (u == 0) break;
            if (S[u] == 'E')
            {
                C[u - 1] = C[u] + 1;
                D[u - 1] = D[u];
            }
            else
            {
                C[u - 1] = C[u];
                D[u - 1] = D[u] + 1;
            }
        }

        long ans = long.MaxValue;
        for (int i = 0; i < N; i++)
        {
            long cnt = B[i] + C[i];
            chmin(ref ans, cnt);
        }
        WriteLine(ans);
        
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 16736
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=2e5+5;

int main()
{
    int a,b,c,d;
    scn(a);
    scn(b);
    scn(c);
    scn(d);

    int ans=0;

    if(a<=b)
    {
        cout<<a*c<<endl;
        return 0;
    }

    ans=ans+b*c;
    a=a-b;

    ans=ans+a*d;
    cout<<ans<<endl;
}



Measured memory_bytes: 3732
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int64_t K;
    cin >> K;
    int64_t modsum = 0;
    int64_t i = 0;
    for(; i<=K; ++i) {
        int64_t m = 7 % K;
        modsum += m;
        if(modsum == 0 || modsum == K) {
            cout << i+1 << endl;
            return 0;
        }
        modsum *= 10 % K;
        modsum %= K;
    }
    cout << -1 << endl;

    return 0;
}


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

int m, d, n;


int main() {
	cin >> n >> m >> d;
	
	double ans = (double)(m - 1) / n / n;

	if (d == 0)
		ans *= n;
	else
		ans *= 2 * (n - d);
	printf("%.15lf\n", ans);

	return 0;
	
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  cout << (s != "AAA" && s != "BBB" ? "Yes" : "No") << '\n';
  return 0;
}


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

long allsum(long x,long y){
  if(x < 10){
    return x + y;
  }
  long sum = 0;
  long i = 1;

  sum += x + y;
  while(x / i >= 10){
    sum += allsum(x / (i * 10),y + x % (i * 10));
    i *= 10;
  }
  return sum;
}

int main(){
  string S;
  long num;
  long N;

  cin >> S;
  num = stol(S);
  N = allsum(num,0);
  cout << N << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,n;
	string s;
	cin>>s>>k;
	n=s.size();
	ll dp[101][2][4];
	rep(i,101)rep(j,2)rep(l,4)dp[i][j][l]=0;
	dp[0][0][0]=1;
	rep(i,n){
		rep(j,4){
			rep(l,10){
				if(j+(l!=0)>=4)continue;
				dp[i+1][1][j+(l!=0)]+=dp[i][1][j];
				if(l<(s[i]-'0'))dp[i+1][1][j+(l!=0)]+=dp[i][0][j];
				if(l==(s[i]-'0'))dp[i+1][0][j+(l!=0)]+=dp[i][0][j];
			}
		}
	}
	puta(dp[n][0][k]+dp[n][1][k]);
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Diagnostics;

namespace CompetitiveProgramming
{
  class Solve
  {
    public Solve()
    {
      int NegativeCount = 0;
      bool HasZero = false;

      int a = Scanner.nextInt();
      int b = Scanner.nextInt();

      if (a <= 0 && b >= 0) {
        HasZero = true;
      }

      if (a < 0) {
        NegativeCount += -a;
      }
      if (b < 0) {
        NegativeCount -= -b + 1;
      }
      if (HasZero) {
        Console.WriteLine("Zero");
      } else if (NegativeCount % 2 == 0) {
        Console.WriteLine("Positive");
      } else {
        Console.WriteLine("Negative");
      }
    } 
  }

  class Program
  {
    static void Main(string[] args)
    {
        new Solve();
    }
  }

  public class Pair<T, U>
  {
    public Pair()
    {

    }
    public Pair(T first, U second)
    {
      this.first = first;
      this.second = second;
    }
    public T first { get; set; }
    public U second { get; set; }
  }

  class Scanner
  {
    private static List<string> buf = new List<string>();

    private static void next()
    {
      if (buf.Count == 0)
      {
        buf = Console.ReadLine().Split().ToList();
      }
    }

    private static string pop()
    {
      string ret = buf[0];
      buf.RemoveAt(0);
      return ret;
    }

    public static int nextInt()
    {
      next();
      return int.Parse(pop());
    }
    public static long nextLong()
    {
      next();
      return long.Parse(pop());
    }
    public static string nextString()
    {
      next();
      return pop();
    }
    public static double nextDouble()
    {
      next();
      return double.Parse(pop());
    }
  }
}


Measured memory_bytes: 2904
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    int a, b, c, d, e, k;
    cin>>a>>b>>c>>d>>e>>k;
    if(k>=std::abs(a-b)&&
    k>=std::abs(a-c)&&
    k>=std::abs(a-d)&&
    k>=std::abs(a-e)&&
    k>=std::abs(b-c)&&
    k>=std::abs(b-d)&&
    k>=std::abs(b-e)&&
    k>=std::abs(c-d)&&
    k>=std::abs(c-e)&&
    k>=std::abs(d-e)){
        cout<<"Yay!"<<endl;
    }else
    {
        cout<<":("<<endl;
    }
    return 0;
    

}

Measured memory_bytes: 256
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[105],ans=0;
inline int read(){
	char ch=getchar();
	int x=0,f=1;
	while(ch<'0' || ch>'9')	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
    n=read();
    a[0]=a[n]=2147483647;
    for(int i=1;i<=n;i++){
    	if(i!=n){
    		a[i]=read();
		}
    	ans+=min(a[i],a[i-1]);
	}
    printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 128
import std.stdio;
import std.datetime;

int[] day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

void main(){
	int[2] y, m, d, s;
	while (readf("%d %d %d %d %d %d\n", &y[0], &m[0], &d[0], &y[1], &m[1], &d[1]), y[0] != -1) {
		// get days from 0001 / 01 / 01
		for (int i = 0; i < 2; i++) {
			s[i] = 0;
			for (int j = 1; j < y[i]; j++) {
				if (yearIsLeapYear(j)) s[i]++;
				s[i] += 365;
			}
			for (int j = 1; j < m[i]; j++) {
				if(j == 2 && yearIsLeapYear(y[i])) s[i]++;
				s[i] += day[j];
			}
			s[i] += d[i] - 1;
		}
		writeln(s[1] - s[0]);
	}
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

int dp[110][5][5][5];

signed main(){
  int n;
  cin >> n;
  // A1 G2 C3 T4
  rep(j,0,5){
    rep(s,0,5){
      rep(t,0,5){
        dp[3][j][s][t] = 1;
      }
    }
  }
  dp[3][0][1][2] = 0;
  dp[3][0][2][1] = 0;
  dp[3][1][0][2] = 0;
  rep(i,4,n+1){
    rep(k,0,4){
      rep(j,0,4){
        rep(s,0,4){
          rep(t,0,4){
            dp[i][j][s][t] += dp[i-1][k][j][s];
            dp[i][j][s][t] %= MOD;
          }
        }
      }
    }
    rep(s,0,4){
      dp[i][0][1][2] -= dp[i-1][s][0][1];
    }
    rep(s,0,4){
      dp[i][0][2][1] -= dp[i-1][s][0][2];
    }
    rep(s,0,4){
      dp[i][1][0][2] -= dp[i-1][s][1][0];
    }
    rep(s,0,4){
      dp[i][s][1][2] -= dp[i-1][0][s][1];
    }
  }
  int ans = 0;
  rep(i,0,4){
    rep(j,0,4){
      rep(s,0,4){
        ans += dp[n][i][j][s];
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

vector<int> divisor(int n)
{
  vector<int> res;
  for (int i=1; i*i<=n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  map<int, int> mp;
  rep(i, n) {
    mp[a[i]]++;
  }
  int ans = 0;
  rep(i, n) {
    mp[a[i]]--;
    vector<int> d = divisor(a[i]);
    bool flg = true;
    for (auto v:d) {
      if (mp[v] > 0) {
        flg = false;
      }
    }
    if (flg) ans++;
    mp[a[i]]++;
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll dp[k+1]={0};
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    dp[0]=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=arr[j])
            {
                if(!dp[i-arr[j]])
                 dp[i]=1;
                 
            }
            else
            break;
        }
    }
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
    
 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	ll h;
	cin >> h;
	ll n = 1;
	ll ans = 0;
	while (h > 0) {
		ans += n;
		n *= 2;
		h /= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char t[1000001], p[10001];
    int jt[10001];
    cin.getline(t, 1000001);
    int tl=cin.gcount()-1;
    cin.getline(p, 10001);
    int pl=cin.gcount()-1;
    if(pl>tl) return 0;
 
    jt[0]=-1;
    jt[1]=0;
    int i=2, j=0;
    while(i<=pl){
        if(p[i-1]==p[j]){
            jt[i]=j+1;
            ++i;
            ++j;
        } else if(j>0) j=jt[j];
        else jt[i++]=0;
    }
    i=j=0;
    while(i<tl){
        if(t[i]==p[j]){
            ++i;
            ++j;
            if(j==pl){
                cout<<i-pl<<'\n';
                j=jt[j];
            }
        }else if(j==0) ++i;
        else j=jt[j];
    }
    return 0;
}


Measured memory_bytes: 4236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A);
	cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256