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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    vector<ll> L;

    int N; cin >> N;

    for (int i = 0;i < N;i++){
        ll l; cin >> l;
        L.push_back(l);
    }

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

    ll ans = 0;

    for (int i = 0;i < N-2;i++){
        for (int j = i+1;j < N-1;j++){
            for (int k = j+1;k < N;k++){
                if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    if(L[i]+L[j] > L[k]) ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;

}

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

def getlist():
	return list(map(int, input().split()))

#初期化
N, C = getlist()
Lis = [[0 for i in range(10 ** 5 + 3)] for j in range(C)]
for i in range(N):
	s, t, c = getlist()
	Lis[c - 1][s] += 1
	Lis[c - 1][t] -= 1

#計算
for j in range(C):
	v = "x"
	for i in range(10 ** 5 + 1):
		if Lis[j][i] == 1:
			v = "o"
			Lis[j][i] = "o"
		elif Lis[j][i] == 0:
			Lis[j][i] = v
		elif Lis[j][i] == -1:
			Lis[j][i] = "o"
			v = "x"

ans = 0
for i in range(10 ** 5 + 1):
	val = 0
	for j in range(C):
		if Lis[j][i] == "o":
			val += 1
	ans = max(ans, val)

print(ans)

Measured memory_bytes: 26672
s = input()
n = len(s)

ans = 0
for i in range(2**(n-1)):
    
    add_place = [""] * n
    for j in range(n-1):
        #print(i,j)
        if ((i>>j)&1):
            add_place[j] = "+"
        #print(add_place)
    fomula = ""
    for num, add in zip(s,add_place):
        fomula += num + add
    #print(fomula)
    ans += eval(fomula)
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int a = 0;
    int z = 0;
    boolean testA = false;
    //boolean testZ = false;
    int count = 0;
    
    for(int i=0; i<str.length(); i++){
        if(str.charAt(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=str.length()-1; i>0; i--){
        if(str.charAt(i) == 'Z'){
            z = i;
            break;
        }
    }
    System.out.println(z-a+1);
  }
}

Measured memory_bytes: 26500
#include <iostream>
using namespace std;
int main(void){  
  int n,c,p,a=0,b=0;  
  cin>>n>>c;   
  
for(int i=0;i<c;i++){  
      cin>>p;      
  a=a+p;    
} 
   b=a%(n+1);  
  if(b==0){     
   cout<<a/(n+1)<<endl; 
   } 
   else{ 
       cout<<a/(n+1)+1<<endl;  
  } 
   return 0;
}


Measured memory_bytes: 3092
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print('0' + '\n')
else:
    mul = 1
    for n in arr:
        mul *= n
        if mul > 10**18:
            print('-1' + '\n')
            break
    else:
        print(str(mul) + '\n')

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

typedef long long ll;
//#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
 
using namespace std;

int m[31][100001] = {0};

signed main(){
    
    int  n,C;
    cin >> n >> C;

    REP(i,n){
        int s,t,c;
        cin >> s >> t >> c;
        for(int j = s;j <= t;j++){
            m[c][j] = 1;
        }
    }

    int ans = 0;
    for(int i = 1;i <= 100000;i++){
        int cnt = 0;
        for(int j = 1; j <= C;j++){
            cnt += m[j][i];
        }
        ans = max(ans,cnt);
    }


    cout << ans << endl;
    
    
    return 0;
}
//g++ -std=c++14 code1.cpp



Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a,b;
 cin>>a>>b;
 vector <int> vec(b);
 rep(i,b){
   cin>>vec[i];
 }
  int sum=0;
 rep(j,b){
   sum+=vec[j];
 }
 if(sum>a){
   cout<<-1;
 }
  else{
 cout<<a-sum;
  }
}


Measured memory_bytes: 3708
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	if (n >= 3200) cout << s << endl;

	else cout << "red" << endl;


	

}
	

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

using namespace std;

string s;
int k, n;

signed main() {
	ios::sync_with_stdio(false);

	cin >> s >> k, n = s.size();
	if (s[0] != s[n - 1]) {
		int cnt = 1, tot = 0;
		for (int i = 1; i < n; ++i)
			if (s[i] == s[i - 1]) ++cnt;
			else tot += cnt / 2, cnt = 1;
		tot += cnt / 2;
		cout << tot * k << endl;
	} else {
		int P = 0, S = 0;
		for (int i = 0; i < n; ++i)
			if (s[i] == s[0]) ++P;
			else break;
		for (int i = n - 1; ~i; --i)
			if (s[i] == s[n - 1]) ++S;
			else break;
		if (P == n) {
			cout << n * k / 2 << endl;
			return 0;
		}
		int cnt = 1, tot = 0;
		for (int i = P + 1; i <= n - S; ++i)
			if (s[i] == s[i - 1]) ++cnt;
			else tot += cnt / 2, cnt = 1;
		cout << tot * k + P / 2 + S / 2 + (P + S) / 2 * (k - 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    if len(s) == 2:
        print(s)
    else:
        print("".join([s[i] for i in range(len(s)-1, -1, -1)]))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int P=1e9+7,N=105;
inline int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}
int n,m,res,h[N],v[N],f[N][N];
inline void inc(int&x,int y){x+=y;x<P?:x-=P;}
int main(){
	int i,j,k,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",h+i),v[i]=h[i];
	sort(v+1,v+n+1),m=unique(v+1,v+n+1)-v-1;
	for(i=1;i<=n;i++)h[i]=lower_bound(v+1,v+m+1,h[i])-v;
	for(i=j=1;j<=h[i];j++)f[i][j]=(ll)2*(fpow(2,v[j]-v[j-1]-(j==1))-1)*fpow(2,v[h[i]]-v[j])%P;
	f[i][h[i]+1]=2;
	for(i=2;i<=n;i++){
		for(j=1;j<=h[i-1];j++)inc(f[i][min(j,h[i]+1)],f[i-1][j]);
		if(h[i]>h[i-1]){
			t=fpow(2,v[h[i]]-v[h[i-1]]);
			for(j=1;j<=h[i-1];j++)f[i][j]=(ll)f[i][j]*t%P;
			for(j=h[i-1]+1;j<=h[i];j++)f[i][j]=(ll)f[i-1][h[i-1]+1]*2*(fpow(2,v[j]-v[j-1])-1)%P*fpow(2,v[h[i]]-v[j])%P;
		}else (f[i][h[i]+1]<<=1)%=P;
		inc(f[i][h[i]+1],f[i-1][h[i-1]+1]*2%P);
	}
	for(i=1;i<=m+1;i++)inc(res,f[n][i]);
	printf("%d\n",res);
}

Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
#define ld long double
using namespace std; 
 
const int N = 2e5 + 1000, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 120, lg = 100;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
    int n;
    cin >> n;
    string s = "";
    for(int i = 1; i <= n; i++)
    	s += (char)(i + '0');
	string t = "", q = "";
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		t += (char)(x + '0');
	}
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		q += (char)(x + '0');
	}	
	int ans1 = 0, ans2 = 0, cnt = 0;
    do {
    	cnt++;
    	if(s == t)
    		ans1 = cnt;
    	if(s == q)
    		ans2 = cnt;
	}
	while(next_permutation(s.begin(), s.end()));
	cout << abs(ans1 - ans2) << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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;
const ll INF = 1e10;
const ll MOD = 1e9+7;
int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if (a >= k) cout << a-k << ' ' << b << endl;
    else if (a < k && k <= a + b) cout << 0 << ' ' << a+b-k << endl;
    else cout << 0 << ' ' << 0 << endl;
}


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int mod=1e9+7;

signed main() {
  int n;
  cin >> n;
  vector<int>A(n);
  rep(i,n){
    cin >> A[i];
  }
  map<int,int>mp1,mp2;
  for(int i=0;i<n;i+=2){
    mp1[A[i]]++;
  }
  for(int i=1;i<n;i+=2){
    mp2[A[i]]++;
  }
    int ans = mod;
  {
    int cou1 = mod;
    int num = -1;
    for(auto it : mp1) {
      if(cou1 > n / 2 - it.second) {
        cou1 = n / 2 - it.second;
        num = it.first;
      }
    }
    int cou2 = mod;
    for(auto it : mp2) {
      if(cou2 > n / 2 - it.second && num != it.first) cou2 = n / 2 - it.second;
    }
    if(cou2 == mod) cou2 = n / 2;
    ans = min(ans, cou1 + cou2);
  }
  {
    int cou1 = mod;
    int num = -1;
    for(auto it : mp2) {
      if(cou1 > n / 2 - it.second) {
        cou1 = n / 2 - it.second;
        num = it.first;
      }
    }
    int cou2 = mod;
    for(auto it : mp1) {
      if(cou2 > n / 2 - it.second && num != it.first) cou2 = n / 2 - it.second;
    }
    if(cou2 == mod) cou2 = n / 2;
    ans = min(ans, cou1 + cou2);
  }
  cout << ans << endl;
} 
  
  
  

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 main() {

	int H,W;
	cin >> H >> W;
	vector<string> G(H);
	rep(i,H) cin >> G[i];
	rep(i,H) rep(j,W) {
		if(G[i][j] == '.') continue;
		if(i != 0) {
			if(G[i-1][j] == '#') continue;
		}
		if(i != H-1) {
			if(G[i+1][j] == '#') continue;
		}
		if(j != 0) {
			if(G[i][j-1] == '#') continue;
		}
		if(j != W-1) {
			if(G[i][j+1] == '#') continue;
		}
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
//ITP1-8-A: Toggling Cases
//2019.05.18

#include <stdio.h>

//関数宣言
char tolowr(char c); //大文字 -> 小文字
char toupr(char c);  //小文字 -> 大文字

int main(void)
{
  char c;
  do {
    scanf("%c", &c);
    if ((c >= 'A') && (c <= 'Z')) {
      c = tolowr(c);
    }else if ((c >= 'a') && (c <= 'z')){
      c = toupr(c);
    }else{}
    printf("%c", c);
  } while(c != '\n');
  //printf("\n");
  return 0;
}


//関数定義
char tolowr(char c) {
  return (c + 0x20);
}

char toupr(char c) {
  return (c - 0x20);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long sum = 0;
	for(int i=1;i<=n;++i) {
		if(i%3 == 0 || i%5==0) continue;
		sum += i;
	}
	cout << sum;
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	double a;
	while(cin >> a){
		double y = a*a/19.6;
		for(int i=1;;i++){
			double h = double(5*i-5);
			if(y<=h){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1224
import java.util.*;
import java.io.*;
 
public class Main {
    static char[] s;
    static boolean solved = false;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        s = sc.next().toCharArray();
        boolean[] plus = new boolean[s.length-1];
        divide(plus,0);
    }
    
    public static boolean divide(boolean[] p, int index){
        if(p.length == index){
            if(calc(p)){
                return true;
            }else{
                return false;
            }
        }
        if(divide(p,index+1)){
            return true;
        }
        p[index] = true;
        if(divide(p,index+1)){
            return true;
        }
        p[index] = false;
        return false;
    }
    
    public static boolean calc(boolean[] p){
        if(solved){
            return true;
        }
        int tmp = Integer.parseInt(String.valueOf(s[0]));
        for(int i = 0; i < p.length; i++){
            if(p[i]){
                tmp += Integer.parseInt(String.valueOf(s[i+1]));
            }else{
                tmp -= Integer.parseInt(String.valueOf(s[i+1]));
            }
        }
        if(tmp == 7){
            char op1 = p[0] ? '+' : '-';
            char op2 = p[1] ? '+' : '-';
            char op3 = p[2] ? '+' : '-';
            System.out.println(""+s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3]+"=7");
            return true;
        }else{
            return false;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s;
LL n, k;

int main() {
	cin >> s >> k;
	n = SL(s);
	
	vector<LL> v;
	inc(i, n) {
		if(i == 0 || s[i] != s[i - 1]) { v.PB(0); }
		v.back()++;
	}
	
	LL ans = 0;
	if(SI(v) == 1) {
		ans = n * k / 2;
	} else {
		RF(e, v) { ans += e / 2; }
		ans *= k;
		if(s.front() == s.back()) {
			int x = v.front();
			int y = v.back();
			ans -= (k - 1) * (x / 2 + y / 2 - (x + y) / 2);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
class Dice
  
  def initialize (given_ary)
    @ary = given_ary
  end

  def roll (direction)
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end

  def top
    @ary[0]
  end

end

dice = Dice.new( gets.split.map(&:to_i) )
gets.split('').each do | which |
  dice.roll( which )
end
puts dice.top

Measured memory_bytes: 8672
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N;

int mod = 1e9 + 7;

int pow(int a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int b = pow(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * pow(a, n - 1) % mod;
    }
}

int main() {
    cin >> N;
    map<int, int> mp;
    int j = 1 - N % 2;
    for (int i = 0; i < N; i += 2) {
        mp[i + j] = 2;
    }
    if (N % 2) {
        mp[0] = 1;
    }
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (mp[a] == 0) {
            cout << 0 << endl;
            return 0;
        }
        mp[a]--;
    }
    cout << pow(2, N / 2) << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int nmax = min(a,b);
	printf("%d ",nmax);
	if(a + b <= n) printf("0\n");
	else printf("%d\n",a + b - n);
	}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = 0
for i,x in enumerate(a):
    if i%2==0 and x%2:
        res += 1
print(res)

Measured memory_bytes: 77256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String id = sc.next();
		int m = sc.nextInt(); HashSet<Integer> vs = new HashSet<Integer>();
		for(int i=0;i<m;i++) vs.add(sc.nextInt());
		long[][] dp = new long[2][10]; dp[0][0] = 1;
		int p=1;
		for(int i=1;i<=n;i++) {
			fill(dp[p], 0);
			for(int j=0;j<10;j++) {
				if(id.charAt(n-i) != '*' )  dp[p][(j+v((id.charAt(n-i)-'0')*(i%2==1? 1: 2)))%10] += dp[1-p][j];
				else for(int k: vs) dp[p][(j+v(k*(i%2==1? 1: 2)))%10] += dp[1-p][j];
			}
//			debug(dp[p]);
			p = 1-p;
		}
		System.out.println(dp[1-p][0]);
	}
	
	int v(int v) {
		return v/10 + v%10;
	}

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

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

Measured memory_bytes: 24548
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  bool np[1000000]= {0};
  np[0] = np[1] = 1;
  REP(i,1000000)
    if (!np[i])
      for (int j=i*2; j<1000000; j+=i)
        np[j] = 1;
  vector<int> p;
  REP(i,1000000) if (!np[i]) p.push_back(i);
  typedef long long ll;
  ll aa, bb;
  cin >> aa>>bb;
  ll a = max(2LL, aa-bb);
  ll b = aa+bb;

  int n = b-a+1;
  int e[n];
  REP(i,n) e[i] = INF;
  REP(i, p.size()) {
    int pp = p[i];

    for (ll j=(a+pp-1)/pp*pp; j<=b; j+=pp) {
      if (e[j-a] == -1) continue;

      ll jj = j;
      int cnt = 0;
      while(jj%pp == 0) {
        jj/=pp;
        cnt++;
      }
      //cout << pp <<  " " << j << " " << cnt << endl;
      e[j-a] =  (e[j-a] < cnt) ? -1 : cnt;
    }
  }
  cout << n - count(e, e+n, -1) << endl;
}

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

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL M;scanf("%u",&M);
 int B[1000]; rep(i,M) scanf("%d",&B[i]);
 UL ans=0;
 rep(i,min(M,N)){
  if(A[i]!=B[i]){ ans=((A[i]<B[i])?2:1); break; }
 }
 if(!ans) ans=((N<M)?2:1);
 printf("%u\n", ans-1);
 return 0;
}




Measured memory_bytes: 3192
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a, b):
    s=int(a)-1
    r=int(b)-1
    return s*r

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
const int maxn=109;
int vis[maxn];
int n,k;
bool isnum(int n)
{
    int ans;
    int cnt;
    while(n)
    {
        ans=n%10;
        if(vis[ans])
        return false;
        n=n/10;
    }
    return true;
}
int main()
{
    while(scanf("%d%d",&n,&k)!=EOF)
    {

        memset(vis,0,sizeof(vis));
        for(int i=0;i<k;i++)
        {   int a;
            scanf("%d",&a);
            vis[a]=1;
        }

        for(int i=n;;i++)
        {
            if(isnum(i))
            {printf("%d\n",i);
            break;
            }
        }


    }
    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
    void solve(std::istream &in, std::ostream &out) {
        std::string s;
        in >> s;
        if (s.length() > 3 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
            out << "Yes";
        } else {
            out << "No";
        }
    }
};


int main() {
    TaskA solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int prime_fact(ll x) {
	int res = 1;
	for (ll i = 2; (ll)i * i <= x; i++) {
		if (x % i != 0) continue;
		res++;
		while (x % i == 0) x /= i;
	}
	if (x != 1) res++;
	return res;
}
int main() {
	ll a, b;
	cin >> a >> b;
	cout << prime_fact(gcd(a, b));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;

    ll k = 0;
    while (k*(k+1) != 2*N) {
        if (k*(k+1) > 2*N) {
            cout << "No\n";
            return 0;
        }
        k++;
    }
    cout << "Yes\n" << k+1 << "\n";

    vector<vector<ll>> S(k+1, vector<ll>());
    ll num = 1;
    for (ll i = 0; i < k+1; i++) {
        for (ll j = i+1; j < k+1; j++) {
            S[i].push_back(num);
            S[j].push_back(num);
            num++;
        }
    }

    Rep (i, k+1) {
        cout << k << " ";
        for (ll c : S[i]) {
            cout << c << " ";
        }
        cout << endl;
    }

}

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

int main(void){
    int a;
    cin >> a;
    for(int i=0;i*4<=a;++i){
        int j = a - i*4;
        if(j%7==0){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,k;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&k);
	
	if(k>=a)k-=a,a=0;
	else a-=k,k=0;
	
	if(k>=b)b=0,k-=b;
	else b-=k,k=0;
	
	printf("%lld %lld\n",a,b);
	return 0;
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    vector<int> Nums;
    int con = 1;
    int flag = 1;
    for (int i=0;i<S.length()-1;i++){
        if (S[i] != S[i+1]) {
            flag = -flag;
            Nums.push_back(con);
            con = 1;
        } else {
            con++;
        }
    }
    Nums.push_back(con);

    vector<int> ans;
    for (int i=0;i<Nums.size();i=i+2){
        int p = Nums[i]+Nums[i+1];
        if (p % 2 == 0){
            for (int j=0;j<Nums[i]-1;j++){
                ans.push_back(0);
            }
            ans.push_back(p/2);
            ans.push_back(p/2);
            for (int j=0;j<Nums[i+1]-1;j++){
                ans.push_back(0);
            }
        } else {
            for (int j=0;j<Nums[i]-1;j++){
                ans.push_back(0);
            }
            if (max(Nums[i]-1,Nums[i+1]-1) % 2 == 0){
                if (Nums[i] > Nums[i+1]){
                    ans.push_back((p+1)/2);
                    ans.push_back((p-1)/2);
                } else {
                    ans.push_back((p-1)/2);
                    ans.push_back((p+1)/2);
                }
            } else {
                if (Nums[i] > Nums[i+1]){
                    ans.push_back((p-1)/2);
                    ans.push_back((p+1)/2);
                } else {
                    ans.push_back((p+1)/2);
                    ans.push_back((p-1)/2);
                }
            }
            for (int j=0;j<Nums[i+1]-1;j++){
                ans.push_back(0);
            }
        }
    }
    for (int i=0;i<ans.size();i++){
        cout << ans[i];
        if (i != ans.size() - 1){
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1592
/*
  B - Minesweeper
  http://abc075.contest.atcoder.jp/tasks/abc075_b
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {

  int H,W;
  char S[60][60];
  int i,j,ii,jj;

  scanf("%d %d\n", &H,&W);
  for( i=0; i<H; i++ ){
    scanf("%s\n", S[i]);
  }

  for( i=0; i<H; i++ ){
    for( j=0; j<W; j++ ){
      if( S[i][j] == '.' ){
        S[i][j] = '0';
        for( ii=-1; ii<=1; ii++ ){
          for( jj=-1; jj<=1; jj++ ){
            if( (i+ii>=0) && (j+jj>=0) && (i+ii<H) && (j+jj<W) ){
              if( S[i+ii][j+jj] == '#' ){
                S[i][j]++;
              }
            }
          }
        }
      }
    }
  }

  for( i=0; i<H; i++ ){
    printf("%s\n", S[i]);
  }

  return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    vector<vi> e(N);

    int x,y;
    Rep(i,M){
        Scd2(x,y);
        x--,y--;
        e[y].push_back(x);
        e[x].push_back(y);
    }

    vi v(N*2);
    stack<int> s;
    s.push(0);
    while(s.size()){
        int from = s.top()%N;
        int odd = s.top()/N;
        s.pop();

        v[from+odd*N] = 1;

        for( int to : e[from] ){
            if( !odd ) to += N;
            if( v[to] ) continue;
            s.push(to);
        }
    }

    ll A = 0;
    ll B = 0;
    Rep(i,N) A += v[i];
    Rep(i,N) B += v[i+N];

    if( A == N && B == N )
        printf ("%lld\n", 1ll*N*(N-1)/2-M );
    else
        printf ("%lld\n", A*B-M );

    return 0;
}





Measured memory_bytes: 6528
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1 3"# => r#"Yes"#,
r#"2 4"# => r#"No"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
    }

    if a + b >= 10 {
        "error".to_string()
    } else {
        format!("{}", a + b)
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = 10000000;


int n;
int p[100];


int main(){

    int c = 0;
    P f, s;

    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];

        if(i != p[i]){
            c++;

            if(c > 2){
                cout << "NO" << endl;
                return 0;
            }
            if(c == 1){
                f.first = i; f.second = p[i];
            }
            if(c == 2){
                s.first = i; s.second = p[i];
            }
        }
    }

    if(f.first == s.second && f.second == s.first){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  int a=0;
  for(int i=0;i<N-1;i++){
    if(A.at(i)==A.at(i+1))a=1;
  }
  if(a==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
long long n,a,res;
map<long long,long long> mp;
int main()
{
  cin>>n;
  mp[0]=1;
  for (int i=0;i<n;i++)
  {
    long long x;
    cin>>x;
    a+=x;
    mp[a]++;
  }
  for (map<long long,long long>::iterator it=mp.begin();it!=mp.end();it++)
  {
    long long s=it->second;
    res+=s*(s-1)/2;
  }
  cout<<res<<endl;
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  //system("pause");
  return 0;
}



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

// #define ANS  //for answer
#define CMP  //for compe

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifndef DBG
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char *argv[]) {

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");

  ll n;cin>>n;
  ll l[n];REP(i,n)cin>>l[i];
  ll sum=0,mx=0;
  REP(i,n){
    sum+=l[i];
    mx=max(mx,l[i]);
  }
  PRINTl((sum>2*mx?"Yes":"No"));

}

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

typedef long long LL;
const int M=2e5+5;
int a[M];
LL cnt[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	LL ans=0;
	for(int i=1;i<=n;i++)
		ans+=cnt[i]*(cnt[i]-1)/2;
	for(int i=0;i<n;i++)
	{
		int v=a[i];
		printf("%lld\n",ans-cnt[v]*(cnt[v]-1)/2+(cnt[v]-1)*(cnt[v]-2)/2);
	}
	return 0;
}

Measured memory_bytes: 3968
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;
const int MAX_V = half_inf;
vector<int> G[MAX_V];
ll d[MAX_V];

ll dfs(ll s) {
    if (d[s] != -1) return d[s];

    ll res = 0;
    each(m, G[s]) {
        res = max(res, dfs(m) + 1);
    }
    d[s] = res;
    return res;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif


        ll n, m;
        cin >> n >> m;
        rep(i, m) {
            ll x, y;
            cin >> x >> y;
            x--, y--;
            G[x].emplace_back(y);
        }
        rep(i, n) d[i] = -1;
        ll ans = 0;
        rep(i, n) ans = max(ans, dfs(i));

        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 8576
import math
def helon(x1, y1, x2, y2, x3, y3):
    a = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    b = math.sqrt((x3 - x2)**2 + (y3 - y2)**2)
    c = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    s = (a + b + c) / 2
    return(math.sqrt(s * (s - a) * (s - b) * (s - c)))
    
while(True):
    try:
        input = map(float, raw_input().split())
        S = []
        S.append(helon(input[0], input[1], input[2], input[3], input[4], input[5]))
        S.append(helon(input[0], input[1], input[2], input[3], input[6], input[7]))
        S.append(helon(input[0], input[1], input[4], input[5], input[6], input[7]))
        S.append(helon(input[2], input[3], input[4], input[5], input[6], input[7]))
        if(math.fabs(S[0] - S[1] - S[2] - S[3]) < 1e-7):
            print("YES")
        else:
            print("NO")
    except Exception:
        break

Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

int main(int argc, char **argv) {
    int k, n, a1;
    cin >> k >> n;
    cin >> a1;
    int prev = a1;
    int mx = 0;
    for (int i=0; i<n-1; ++i) {
        int a;
        cin >> a;
        mx = max(mx, a-prev);
        prev = a;
    }
    mx = max(mx, a1+(k-prev));

    cout << (k-mx) << endl;

    return 0;
}


Measured memory_bytes: 256
//           _____                  _______                  _____                   _____
//          /\    \                /::\    \                /\    \                 /\    \
//         /::\    \              /::::\    \              /::\____\               /::\    \
//        /::::\    \            /::::::\    \            /:::/    /              /::::\    \
//       /::::::\    \          /::::::::\    \          /:::/    /              /::::::\    \
//      /:::/\:::\    \        /:::/~~\:::\    \        /:::/    /              /:::/\:::\    \
//     /:::/__\:::\    \      /:::/    \:::\    \      /:::/    /              /:::/__\:::\    \
//    /::::\   \:::\    \    /:::/    / \:::\    \    /:::/    /              /::::\   \:::\    \
//   /::::::\   \:::\    \  /:::/____/   \:::\____\  /:::/    /      _____   /::::::\   \:::\    \
//  /:::/\:::\   \:::\    \|:::|    |     |:::|    |/:::/____/      /\    \ /:::/\:::\   \:::\    \
// /:::/  \:::\   \:::\____|:::|____|     |:::|____|:::|    /      /::\____/:::/  \:::\   \:::\____\
// \::/    \:::\  /:::/    /\:::\   _\___/:::/    /|:::|____\     /:::/    \::/    \:::\  /:::/    /
//  \/____/ \:::\/:::/    /  \:::\ |::| /:::/    /  \:::\    \   /:::/    / \/____/ \:::\/:::/    /
//           \::::::/    /    \:::\|::|/:::/    /    \:::\    \ /:::/    /           \::::::/    /
//            \::::/    /      \::::::::::/    /      \:::\    /:::/    /             \::::/    /
//            /:::/    /        \::::::::/    /        \:::\__/:::/    /              /:::/    /
//           /:::/    /          \::::::/    /          \::::::::/    /              /:::/    /
//          /:::/    /            \::::/____/            \::::::/    /              /:::/    /
//         /:::/    /              |::|    |              \::::/    /              /:::/    /
//         \::/    /               |::|____|               \::/____/               \::/    /
//          \/____/                 ~~                      ~~                      \/____/
//I am aqua
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define pii pair< int,int >
#define mp make_pair
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define speed  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define l first
#define r second
#define input.txt ifstream fin("input.txt");
#define output.txt ofstream fout("output.txt");
#define BTT( a,b ) (((a)>>(b))&1)
#define LB(x) (x % -(x))
using namespace std;
//---------------------------------------------------------------------------------------------------------------------
///Variables
const int maxn=100+10;
//--------------------------------------------------------------------------------------------------------------------
///Function

//---------------------------------------------------------------------------------------------------------------------
///Main
int main()
{
    ll n,m;
    cin>>n>>m;
    n%=m;
    cout<<min(n,abs(n-m));
}
//I know that ;
//I know where I am
//Do not think I don't


Measured memory_bytes: 256
from itertools import combinations_with_replacement
N, M, Q = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(Q)]
ans = []
for A in combinations_with_replacement(range(1, M+1), N):
    t = 0
    for x in X:
        if A[x[1]-1]-A[x[0]-1] == x[2]:
            t += x[3]
    ans.append(t)
print(max(ans))


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

int main() {
  string s; cin >> s;
  REP(i,s.length()-1) {
    if (s.substr(i,2)=="AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X;
    cin >> X;
    int now = X;
    while(1){
        if(now%360 == 0){
            cout << now/X << "\n";
            return 0;
        }
        now += X;        
    }

    return 0;
}


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

long long N;
long long A;
long long B;

int main()
{
    cin>>N>>A>>B;

    if (A>B)
    {
        cout<<0<<endl;
        return 0;
    }

    if (N==1 && A==B)
    {
        cout<<1<<endl;
        return 0;
    }

    if (N==1 && A!=B)
    {
        cout<<0<<endl;
        return 0;
    }

    long long lowerbound=(N-1)*A+B;
    long long upperbound=(N-1)*B+A;

    long long ans=upperbound-lowerbound+1;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	int d[n];
	for(int i=0; i<n; i++){
		cin >> d[i];
	}
	sort(d,d+n);
	int split_i=1;
	if(d[(n/2)-1]==d[n/2]){
		cout << 0 << endl;
		return 0;
	}
	cout << d[n/2]-d[(n/2)-1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int H,W;
string s[100];
int dp[100][100];
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)
	{
		cin>>s[i];
		for(int j=0;j<W;j++)
		{
			if(i==0&&j==0)dp[i][j]=s[i][j]=='#';
			else
			{
				dp[i][j]=min(j>0?dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'):1e5,i>0?dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'):1e5);
			}
		}
	}
	cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 256