akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
 
// random_device rd; mt19937 g(rd());
 
using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
const int N = (int)1e3;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
 
bool Less(ld a, ld b)
{
	return a < b;
}
 
struct Point
{
	ld x, y, angle;
 
	Point() { }
 
	Point(ld _x, ld _y, ld _angle) { x = _x, y = _y, angle = _angle; }
 
	ld Scalar_Product(Point a)
	{
		ld curx = a.x * x;
		ld cury = a.y * y;
		return curx + cury;
	}
 
	ld Module()
	{
		ld curx = x * x;
		ld cury = y * y;
		ld cur = curx + cury;
		return (cur);
	}
 
	ld Angle(Point x = Point(1, 0, 0))
	{
		ld Module_All = Module() * x.Module();
		ld alpha = acos(Scalar_Product(x) / Module_All);
		if(Less(y, 0)) alpha = pi + pi - alpha;
		return alpha;	
	}

	bool operator < (const Point &a)
	{
        return atan2(x, y) < atan2(a.x, a.y);
    }
 
	void Read() { cin >> x >> y, angle = Angle(); }
 
}a[N];
 
ld ans;
 
bool cmp(Point a, Point b)
{
	return Less(a.angle, b.angle);
}
 
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) a[i].Read();
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++)
	{
		Point cur = a[i];
		ans = max(ans, cur.Module());
		for(int j = i + 1; j <= n; j++) 
		{
			cur.x += a[j].x, cur.y += a[j].y;
			ans = max(ans, cur.Module());
		}
		for(int j = 1; j < i; j++)
		{
			cur.x += a[j].x, cur.y += a[j].y;
			ans = max(ans, cur.Module());
		}
	}
	cout << fixed << setprecision(13) << sqrt(ans) << endl;
}    

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int cnt=0;
    rep(i,n){
        if(i%2==0&&a[i]%2==1) cnt++;
    }
    cout << cnt;
    return 0;
}

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

        int main() {
          int N, Q; 
          string S;
          cin>> N >> Q; 
          cin >> S; 
          vector<int>A(S.size()); 
          int c=0; 
          A.at(0)=0; 
          for(int i=1; i< S.size(); i++){
          	if(S.at(i-1)=='A' && S.at(i)=='C' ) c++; 
            A.at(i)=c;
          }
          for(int i=0; i<Q; i++){
            int X, Y;
            cin>> X >> Y;
            cout<< A.at(Y-1) - A.at(X-1) << endl; 
          }
        }

Measured memory_bytes: 1408
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		ll dp[n+1][k+1];
		zero(dp);
		dp[0][0]=1;
		vector<ll>a(n+1);
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		for(int i=1;i<=n;i++){
			// cout<<a[i]<<endl;
			vector<ll>sum(k+1,0);
			sum[0]=dp[i-1][0];
			for(int j=1;j<=k;j++){
				sum[j]=(sum[j-1]+dp[i-1][j])%MOD;
			}
			for(int j=0;j<=k;j++){
				dp[i][j]=sum[j];
				if(j>a[i]){
					dp[i][j]=(dp[i][j]-sum[j-a[i]-1]+MOD)%MOD;
				}
			}
		}
		// for(int i=0;i<=n;i++){
		// 	for(int j=0;j<=k;j++){
		// 		cout<<dp[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
		cout<<dp[n][k]<<endl;
	}
}

Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> l(n+1, 0);
    rep1(i, n+1) cin >> l[i];
    LL ans = 0;
    LL t = 0;
    repe(i, l){
        if(t + i <= x){
            ans++;
            t += i;
        }else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

struct Frac {
    long nume;
    long deno;
}

Frac area(long x1, long y1, long x2, long y2, long x3, long y3) {
    long sx = x2 - x1;
    long sy = y2 - y1;
    long tx = x3 - x1;
    long ty = y3 - y1;
    return Frac(abs(sx * ty - tx * sy), 2);
}

void calc(long s) {
    // x2, y2 を固定する
    long x2 = 10 ^^ 9;
    long y2 = 1;

    long y3 = (s + x2 - 1) / x2;
    long x3 = (x2 * y3 - s);

    writefln("%d %d %d %d %d %d", 0, 0, x2, y2, x3, y3);
}

void main() {
    long s = read!long;
    calc(s);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  vi u(2);
  cin >> n >> u[0] >> u[1];
  u[0]--;
  u[1]--;
  vector<vi> g(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vi> d(2, vi(n, -1));
  rep(k, 2) {
    queue<int> q;
    q.push(u[k]);
    d[k][u[k]] = 0;
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      for(auto ni : g[i]) {
        if(d[k][ni] != -1) continue;
        d[k][ni] = d[k][i] + 1;
        q.push(ni);
      }
    }
  }
  int ans = 0;
  rep(i, n) if(d[0][i] < d[1][i]) ans = max(ans, d[1][i]);
  cout << ans - 1 << endl;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,c=0;
  cin>>n;
  for(ll i=1;i<1000008;i++){
    if(n<=i)break;
    if(n%i==0){
      if(n/(n/i)==n/((n/i)-1)) c+=(n/i)-1;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int k;
	cin >> k;
	ll ans = 0;
	for (int i = 1; i <= k; i++) for (int j = 1; j <= k; j++) for (int m = 1; m <= k; m++) {
		ans += gcd(gcd(i, j), m);
	}
	cout << ans << endl;
	return 0;
}

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

namespace id_0619cs
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> vsScience = new List<int>();
            vsScience.Add(int.Parse(Console.ReadLine()));
            vsScience.Add(int.Parse(Console.ReadLine()));
            vsScience.Add(int.Parse(Console.ReadLine()));
            vsScience.Add(int.Parse(Console.ReadLine()));
            vsScience.Sort();

            List<int> vsSocial = new List<int>();
            vsSocial.Add(int.Parse(Console.ReadLine()));
            vsSocial.Add(int.Parse(Console.ReadLine()));
            vsSocial.Sort();
            Console.WriteLine(vsScience.Skip(1).Take(3).Sum() + vsSocial.Skip(1).Take(1).Sum());
        }
    }
}



Measured memory_bytes: 18316
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int[] pow3 = new int[16], c = new int[16];
        int n, m, i, j, k, d, x, y, p;
        pow3[0] = 1;
        for(i = 1; i <= 15; ++i)
        {
        pow3[i] = pow3[i-1] * 3;
        }
        while(true){
            n = in.nextInt();
            m = in.nextInt();
            if(n == 0 && m == 0)break;
            for(i = 0;i<3;i++){
                for(j = in.nextInt(); j > 0; --j){
                    k = in.nextInt();
                    c[n-k] = i;
                }
            }
            
            p = 0;
            x = 0;
            for(i = n - 1; i >= 0; --i){
                d = Math.abs(p - c[i]);
                x += pow3[i] * d;
                if(d == 1) p = 2 - p;
            }
            y = pow3[n] - 1 - x;
            if(x > y) x = y;
            if(m < x) System.out.println("-1");
            else System.out.println(x);
        }
        in.close();
    }
}



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

int main(){
    //シャッフル回数ｍ
    //下からx枚とってシャッフル
    int m,x;
    char tmp;
    string s = "";

    while(1){
        cin >> s;
        cin >> m;
        if(s == "-"){
            break;
        }
        //もしxがh＝xのシャッフルをするなら、
        //下からx枚の紙を上に持ってくる
        //下からx番目から下の紙すべてをなんらかのboxに移し        
        //残ったものを一番下まで動かす。
        //空いた上の場所にさっき移した紙を戻す
        for(int i = 0 ; i<m ; i++){
            cin >> x;
            for(int j= 0; j< x; j++){
                tmp = s[0];
                s.erase(s.begin());           
                s.insert(s.end(), tmp);
            }
        }                
        cout << s << endl;
    }
}




Measured memory_bytes: 3200
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

H, W = mi()
S = []
#周りを囲う
S.append('#'*(W+2))
for _ in range(H):
  S.append(''.join(('#',input(),'#')))
S.append('#'*(W+2))

#まずは行を走査
#各行各セルの横向きに繋がったマスを入れる配列を作る
hnum = [[0]*(W+2) for _ in range(H+2)] #添字を揃えるためにダミーを入れる

for i in range(1, H+2): #1～H以外はダミーだが、H+1も走査しないと障害物にぶつからず、処理されない。iはその時の行番号を示す
  noww = 0 #今見ている列の番号
  tmphnum = 0 #現状繋がっているセルの数を入れていく
  tmphnumstartidx = -1 #繋がり始めたセルの列番号。最初は「未発見」の意を表す-1を入れておく
  for cell in S[i]: #行の各セルを走査
    if cell=='#': #hnumは元々0が入っているので今回いじらなくていい
      #ただし、連結が途切れた場合の処理が必要
      if tmphnumstartidx != -1:
        #連結部分のhnumに、tmphnumを代入する
        for j in range(tmphnumstartidx, noww): #1つ前まで全て
          hnum[i][j] = tmphnum
        tmphnumstartidx = -1 #フラグを兼ねているので、-1にリセット
        tmphnum = 0 #連結セル数も、途切れたので0にリセット
    else: #セルが'.'だった場合
      #繋がるセルの中で一番左端なら、繋がり始めの処理をする
      if tmphnumstartidx == -1:
        tmphnum = 1
        tmphnumstartidx = noww
      else: #左のセルに連結したなら
        tmphnum += 1 #連結セルが1個増えた
    #なんにせよ、noww+=1して次のセル番号に変える
    noww += 1

#今度は列を走査して、ansを最大値で更新していく
ans = 0
#列は文字列になっていないので、計算は遅いかもしれないが、直接S[][]で読んでいくことにする

#今度はiが列番号を表しているので注意！！
for i in range(1, W+2): #1～W以外はダミーだが、W+1も処理しないと障害物にぶつからず処理されないから困る。iはその時の列番号を示す
  tmpwnum = 0 #現状繋がっているセルの数を入れていく
  tmpwnumstartidx = -1 #繋がり始めたセルの行番号。最初は「未発見」の意を表す-1を入れておく
  #今度はjが行番号を表しているので注意！！
  for j in range(1, H+2): #列の各セルを走査
    cell = S[j][i] #わかりやすくするためcellに代入
    if cell=='#': #hnumは元々0が入っているので今回いじらなくていい
      #ただし、連結が途切れた場合の処理が必要
      #ちなみに、#の場合が答えになるはずはないので、答えの判定はしなくていい
      if tmpwnumstartidx != -1:
        #連結が途切れた場合の処理、つまり一つ前のセルまでの答え判定
        #pは、遡って見ているセルの行番号を示す
        for p in range(tmpwnumstartidx, j): #1つ前まで全て
          ans = max(tmpwnum + hnum[p][i] - 1, ans)
        tmpwnumstartidx = -1 #フラグを兼ねているので、-1にリセット
        tmpwnum = 0 #連結セル数も、途切れたので0にリセット
    else: #セルが'.'だった場合
      #繋がるセルの中で一番上なら、繋がり始めの処理をする
      if tmpwnumstartidx == -1:
        tmpwnum = 1
        tmpwnumstartidx = j
      else: #左のセルに連結したなら
        tmpwnum += 1 #連結セルが1個増えた

print(ans)


Measured memory_bytes: 93276
import math
n = int(input())
count = 0
for i in range(1, n):
    if (math.floor(n/i) == n/i):
        res = n/i - 1
        if(i == res):
            count += 1
        if(res<= i):
            print(int(count))
            exit()
    else:
        res = math.floor(n/i)
        if(i == res):
            count += 1
        if(res<= i):
            print(int(count))
            exit()
    count = count + (res-i+1)*2 - 1
print(int(count))

Measured memory_bytes: 9204
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
int n,a,b;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	while(cin>>a>>b){
		
		
		n=a+b;
		int counter=0;
		while(n){
			n=n/10;
			counter++;
		}
		cout<<counter<<"\n";		
	}

	return 0;
}

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

int dp[100100];
int h[100100];

signed main ( ) {

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

    int n, k;
    cin >> n >> k;
    for ( int i = 0; i < n; i++ ) {
        cin >> h[i];
    }
    for ( int i = 0; i < 100100; i++ ) {
        dp[i] = 0x3f3f3f3f;
    }

    dp[0] = 0;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 1; j <= k; j++ ) {
            dp[i+j] = min ( dp[i+j], dp[i] + abs(h[i]-h[i+j]) );
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/11/22.
//

#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#define MAXN 10000
using namespace std;

int n, e;
vector<int> graph[MAXN];
queue<int> q;
vector<int> out;
bool visited[MAXN];
int indegree[MAXN];

void init(){
    fill(visited, visited+n, false);
    find(indegree, indegree+n, 0);
}

void bfs(int node){
    q.push(node);
    visited[node] = true;
    out.push_back(node);
    while (!q.empty()){
        int u = q.front();
        q.pop();
        vector<int>::iterator it;
        for (it = graph[u].begin(); it != graph[u].end(); ++it){
            visited[*it] = true;
            indegree[*it]--;
            if (!indegree[*it]){
                out.push_back(*it);
                q.push(*it);
            }
        }
    }
}

int main(){
    scanf("%d %d", &n, &e);
    init();
    int u, v;
    for (int i = 0; i < e; ++i) {
        scanf("%d %d", &u, &v);
        graph[u].push_back(v);
        indegree[v]++;
    }
    for (int i = 0; i < n; ++i) {
        if (!visited[i] && !indegree[i]){
            bfs(i);
        }
    }
    vector<int>::iterator it;
    for (it = out.begin(); it != out.end(); ++it){
        printf("%d\n", *it);
    }
}
/*
6 6
0 1
1 2
3 1
3 4
4 5
5 2
 */


Measured memory_bytes: 3560
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    cin>>n;
    lli arr[n+1]={0};
    FOR(i,n-1){
        cin>>temp;
        arr[temp]++;
    }
    for(i=1;i<=n;i++)cout<<arr[i]<<endl;
 
}

Measured memory_bytes: 5124
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  cout << fixed << setprecision(6) << (double)sqrt(abs(x2-x1)*abs(x2-x1)+abs(y2-y1)*abs(y2-y1)) << endl;
}


Measured memory_bytes: 3236
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    cout << "A" << b[0]  <<  "C" << endl;
    return 0;
}

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

int main(){
    int X, A, B;
    cin >> X >> A >> B;

    if(A - B >= 0){
        cout << "delicious" << endl;
    }else if(B - A <= X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    ll ans = 0;
    rep(i,n-1)
    {
        REP(j, i+1, n)
        {
            ans += ary[i] * ary[j];
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 5e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, r[N], a[N], b[N];
int cur = 3e4;

void solve() { 
  cin >> n;
  for (int i = 1;i <= n;i++) {
    int x; cin >> x;
    r[x] = i;
    a[i] = i * cur;
    b[i] = (n - i + 1) * cur;
  }
  for (int i = 1;i <= n;i++) cout << a[i] << " ";
  cout << endl;
  for (int i = 1;i <= n;i++) cout << b[i] + r[i] << " ";
  cout << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
  // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int cal(int val,int tax) {
	return val * (100 + tax) / 100;
}
int main(){
	int x, y, s;
	while (cin >> x >> y >> s) {
		if (x == 0)break;
		int ma = 0;
		for (int i = 1; i < s; i++) {
			for (int j = i; j < s; j++) {
				if (cal(i, x) + cal(j, x) == s) {
					ma = max(ma, cal(i, y) + cal(j, y));
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1;
  int dy=y2-y1;
  int x3=x2-dy;
  int y3=y2+dx;
  int x4=x3-dx;
  int y4=y3-dy;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
#define gcd __gcd
#define lcm(a, b) (a / gcd(a, b) * b)
#define factorial(a) (a < 2 ? 1 : factorial(a - 1) * a)
#define summation(a) (a < 1 ? 0 : (a * a + a) / 2)
const int INF = 1e18, MOD = 1e9 + 7;

vector<int> fact;

void modinit(int n) {
    fact.push_back(1);
    int now = 1;
    for (int i = 1; i <= n; i++) {
        now *= i;
        now %= MOD;
        fact.push_back(now);
    }
}

int modpow(int x, int n) {
    return n < 1 ? 1 : modpow(x * x % MOD, n / 2) * (n % 2 ? x : 1) % MOD;
}

int modcomb(int n, int r) {
    if (n < r) return 0;
    return fact[n] * modpow(fact[n - r], MOD - 2) % MOD * modpow(fact[r], MOD - 2) % MOD;
}

int n;

signed main() {
    INCANT;
    cin>>n;
    int x = 0;
    int a[222222];
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        x ^= a[i];
    }
    cerr<<x;
    for (int i = 0; i < n; i++) {
        cout<<(a[i]^x)<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 5180
#include <iostream>

using namespace std;

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

	while(n --){
		int y, m, d; cin >> y >> m >> d;
		int count = 0;
		for(; y < 1000; y ++, m = 1)
			for(; m <= 10; m ++, d = 1)
				for(; d <= ((y % 3 && !(m % 2)) ? 19:20); d ++)
					count ++;
		cout << count << endl;
	}

	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
    int h , w ; cin >> h >> w ;
  rep(i,h){
    rep(j,w){
      string s; cin>>s;
      if(s=="snuke"){
        cout<<(char)('A'+j)<<i+1<<endl;
        break;
      }
    }
  }
}



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

using namespace std;

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

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	vector<int>w(N);
	for(auto &i:w)cin>>i;
	vector<int>v(4);
	for(auto i:w){
		v[i%3]++;
	}
	if(v[0]==N){
		cout<<1<<endl;
		return 0;
	}
	if(v[1]==N){
		cout<<min(3,N)<<endl;
		return 0;
	}
	if(v[2]==N){
		cout<<min(3,N)<<endl;
		return 0;
	}
	int ans=1;
	if(v[1]>=2){
		ans=max(ans,2+min(v[2],v[1]-2)*2+v[0]);
	}
	if(v[1]>=3){
		ans=max(ans,3+min(v[2],v[1]-3)*2+v[0]);
	}
	if(v[2]>=2){
		ans=max(ans,2+min(v[1],v[2]-2)*2+v[0]);
	}
	if(v[2]>=3){
		ans=max(ans,3+min(v[1],v[2]-3)*2+v[0]);
	}
	if(v[1]&&v[2]){
		ans=max(ans,2+min(v[1]-1,v[2]-1)*2+v[0]);
	}
	if(v[1]){
		ans=max(ans,1+min(v[1]-1,v[2])*2+v[0]);
	}
	if(v[2]){
		ans=max(ans,1+min(v[2]-1,v[1])*2+v[0]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
   int n;
   cin >> n;
   long long all = 0;
   
   vector<int> kazu(n);
   
   for ( int i = 0; i < n; ++i ){
       cin >> kazu.at(i);
       all = all + kazu.at(i);
   }
    sort ( kazu.begin(), kazu.end() );

   cout << kazu.at(0) << " " << kazu.at( n - 1 ) << " " << all << endl;
    
}


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

const int t[14] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

int main(void) {
	int m, d, a;

	while (cin >> m >> d, m) {
		a = (t[m-1] + d) % 7;
		if (a == 0) cout << "Wednesday";
		else if (a == 1) cout << "Thursday";
		else if (a == 2) cout << "Friday";
		else if (a == 3) cout << "Saturday";
		else if (a == 4) cout << "Sunday";
		else if (a == 5) cout << "Monday";
		else cout << "Tuesday";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	bingo := make([]int, 9)
	exist := make([]bool, 9)
	res := "No"
	for i := 0; i < 9; i++ {
		bingo[i] = nextInt()
	}

	n := nextInt()
	for i := 0; i < n; i++ {
		num := nextInt()
		for j := 0; j < 9; j++ {
			if bingo[j] == num {
				exist[j] = true
				continue
			}
		}
	}

	for i := 0; i < 3; i++ {
		//横[0,1,2][3,4,5][6,7,8]
		if exist[i] && exist[i*3+1] && exist[i*3+2] {
			res = "Yes"
		}
		//縦[0,3,6][1,4,7][2,5,8]
		if exist[i] && exist[i+3] && exist[i+6] {
			res = "Yes"
		}
	}
	//斜[0,4,8][2,4,6]
	if exist[0] && exist[4] && exist[8] || exist[2] && exist[4] && exist[6] {
		res = "Yes"
	}
	fmt.Println(res)
}

Measured memory_bytes: 640
n, m, x, y = (int(i) for i in input().split())
list_x = sorted(list(map(int, input().split())))
list_y = sorted(list(map(int, input().split())))
if max(x ,list_x[-1]) < min(y, list_y[0]):
    print("No War")
else:
    print("War")

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
int t[1010000];
int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i*n+j*m-2*i*j>1000000) break;
            if(i*n+j*m-2*i*j<0) continue;
            t[i*n+j*m-2*i*j]=1;
        }
    }
    //for(int i=0;i<1000;i++) printf("%d ",t[i]);
    if(t[k]==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    int d=abs(a-b),r=v-w;
    if(d and r<=0){
        cout << "NO";
    }
    else{
        if(t*r>=d)cout << "YES";
        else cout << "NO";
    }
}

Measured memory_bytes: 3652
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    A = list(map(int, stdinput().split()))

    count = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            count += 1
    
    print(' '.join(map(str, A)))
    print(count)

if __name__ == '__main__':
    main()


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

typedef struct point_xy_tag{
	double x ;
	double y ;
}Vector2D, Vertex2D;

Vector2D new_vector2D(Vertex2D a, Vertex2D b){
	Vector2D c;
	c.x = a.x - b.x;
	c.y = a.y - b.y;
	return c;
}//??§?¨????????????????????????????????????????Vector2D???????????°????????????

double gaiseki(Vector2D a, Vector2D b){
	return a.x*b.y - a.y*b.x;
}

int main(void) {
	Vertex2D a, b, c, p;
	int max, i;
	double op[100][3];
	
	//while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
	//while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
	//i = 0;
	//while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
	//	&a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &p.x, &p.y)
	//	!= EOF){
	for(i=0; scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
		&a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &p.x, &p.y)
		!= EOF; i++){
		
		//double c1 = gaiseki(new_vector2D(p, a), new_vector2D(b, a));
		//double c2 = gaiseki(new_vector2D(p, b), new_vector2D(c, b));
		//double c3 = gaiseki(new_vector2D(p, c), new_vector2D(a, c));
		op[i][0] = gaiseki(new_vector2D(p, a), new_vector2D(b, a));
		op[i][1] = gaiseki(new_vector2D(p, b), new_vector2D(c, b));
		op[i][2] = gaiseki(new_vector2D(p, c), new_vector2D(a, c));
	}
	max = i;
	
	for(i=0; i<max; i++){
		//if((c1>0.0 && c2>0.0 && c3>0.0) || (c1<0.0 && c2<0.0 && c3<0.0)){
		if((op[i][0]>0.0 && op[i][1]>0.0 && op[i][2]>0.0) || 
		(op[i][0]<0.0 && op[i][1]<0.0 && op[i][2]<0.0)){
			printf("YES");
		}else{
			printf("NO");
		}
		//if(i != (max-1)){
			printf("\n");
		//}
	}
	
	return 0;
}

/*
2016/10/30 13:56:42

*/

Measured memory_bytes: 620
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		200005									// 最大文字列数
#define D_STR_LEN		10										// 文字列長

// 内部変数
static FILE *szpFpI;											// 入力
static char sc2Str[D_STR_MAX][D_STR_LEN + 5];					// 文字列
static char *scp1Str[D_STR_MAX];								// 文字列
static int siSCnt;												// 文字列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// ソート関数 - char昇順
int
fSortFncCU(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	char *lcpVal1 = (char *)pzpVal1;
	char *lcpVal2 = (char *)pzpVal2;

	// char昇順
	if (*lcpVal1 > *lcpVal2) {
		return 1;
	}
	else if (*lcpVal1 < *lcpVal2) {
		return -1;
	}

	return 0;
}

// ソート関数 - 文字列昇順
int
fSortFncSU(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	char **lcppVal1 = (char **)pzpVal1;
	char **lcppVal2 = (char **)pzpVal2;

	// 文字列昇順
	return strncmp(*lcppVal1, *lcppVal2, D_STR_LEN);
}

// 実行メイン
long long
fMain(
)
{
	int i, liRet;
	char lc1Buf[1024];

	// 文字列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siSCnt);

	// 文字列 - 取得
	for (i = 0; i < siSCnt; i++) {
		fgets(sc2Str[i], sizeof(sc2Str[i]), szpFpI);
		qsort(sc2Str[i], D_STR_LEN, sizeof(char), fSortFncCU);
		scp1Str[i] = sc2Str[i];
	}
	sc2Str[siSCnt][0] = 0;
	scp1Str[siSCnt] = sc2Str[siSCnt];

	// 文字列 - ソート
	qsort(scp1Str, siSCnt, sizeof(char *), fSortFncSU);

	// 個数 - 取得
	long long llCnt = 0;
	long long llSame = 1;
	for (i = 0; i < siSCnt; i++) {
		
		// 次と比較
		liRet = fSortFncSU(&scp1Str[i], &scp1Str[i + 1]);
		if (liRet == 0) {
			llSame++;
		}
		else {
			llCnt += llSame * (llSame - 1) / 2;
			llSame = 1;
		}
	}

	return llCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main() {
  int n, l;
  cin >> n >> l;
  if (l > 0) cout << (2 * l + n) * (n - 1) / 2 << endl;
  else if (l + n - 1 < 0) cout << (2 * l + n - 2) * (n - 1) / 2 << endl;
  else cout << (2 * l + n - 1) * n / 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  while(scanf("%d",&n),n){
    int b[10]={0};
    for(;n--;b[i]++)scanf("%d",&i);;
    for(i=0;i<10;i++){
      if(b[i]){
	while(b[i]--)printf("*");
	printf("\n");
      }
      else printf("-\n");
    }
  }
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(2, vector<int>(n));
  for(int i=0;i<2;i++)for(int j=0;j<n;j++){
    cin>>a[i][j];
  }
  
  int ans=0, cnt;
  for(int k=0;k<n;k++){ //どこで下に降りるか
    cnt=0;
    for(int j=0;j<n;j++){
      if(j<k){
        cnt+=a[0][j];
      }else if(j>k){
        cnt+=a[1][j];
      }else{
        cnt+=a[0][j]+a[1][j];
      }
    }
    ans=max(ans, cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int maxn = 1e2+2;

char mp[maxn][maxn];
int dp[maxn][maxn];
bool vis[maxn][maxn];
int n,m;

void sol(int x,int y,int v){
    dp[x][y]=min(dp[x][y],v);
    int nx=x+1,ny=y;//down
    if(nx<=n&&mp[nx][ny]=='#'&&!vis[nx][ny]) {
        vis[nx][ny]=true;
        sol(nx,ny,v);
    }
    nx=x,ny=y+1;//right
    if(ny<=m&&mp[nx][ny]=='#'&&!vis[nx][ny]) {
        vis[nx][ny]=true;
        sol(nx,ny,v);
    }
}

int main(){
//    op;
    read(n);read(m);
    fo(i,1,n) scanf("%s",mp[i]+1);
    fo(i,0,n+1){
        fo(j,0,m+1) dp[i][j]=dp[i][j]=INF;
    }
    dp[0][1]=dp[1][0]=0;
    fo(i,1,n){
        fo(j,1,m){
            int nw=mp[i][j]=='#';
            //如果我是黑色，那么我就进行翻转
            if(nw==1){
                int mi=min(dp[i-1][j],dp[i][j-1])+1;
                sol(i,j,mi);
                me0(vis);
            }
            else{
                dp[i][j]=min(dp[i][j],min(dp[i-1][j],dp[i][j-1]));
            }
        }
    }

    printf("%d\n",dp[n][m]);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	
	long long int a,b,c;
	scanf("%lld %lld",&a,&b);
	if(a<=5)
		b=0;
	else if (a>5 && a<=12)
		b=b/2;

		printf("%lld\n",b);

	
	return 0;
}






Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

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

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration


int main() {
	int N,K,tab[200005],range=0;
	cin>>K>>N;
	cin>>tab[0];
	range=tab[0];
	for(int i=1 ; i<N ; ++i){
		cin>>tab[i];
		range=max(range,tab[i]-tab[i-1]);
	}
	range=max(range,min(tab[N-1]-tab[0],K-(tab[N-1]-tab[0])));

	cout<<K-range<<endl;
	return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: String = read!(String);
    let first = &s[0..2];
    let second = &s[2..4];
    let fi: i32 = first.parse().unwrap();
    let si: i32 = second.parse().unwrap();

    if 1 <= fi && fi <= 12 {
        // MMYYの可能性あり
        if 1 <= si && si <= 12 {
            // どちらの可能性もあり
            println!("AMBIGUOUS");
        } else {
            println!("MMYY");
        }
    } else if 1 <= si && si <= 12 {
        // YYMMの可能性あり
        if 1 <= fi && fi <= 12 {
            println!("AMBIGUOUS");
        } else {
            println!("YYMM");
        }
    } else {
        // どちらの可能性もない
        println!("NA");
    }
}


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

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

ll ans;
string s;

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i;

    cin>>s;
    ll cnt = 0;
    for(i=0; i<s.size(); i++)
    {
        if(s[i]=='B') cnt++;
        else ans+=cnt;
    }

    cout<<ans;
    return 0;
}


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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,ans=0;
  cin>>n;
  rep(i,1,n+1)
    {
      int cnt=0,tmp=i;
      while(tmp)
	{
	  cnt++;
	  tmp/=10;
	}
      if(cnt&1) ans++;
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

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

    if ((a+b+c) == 17) {
        if (a == 5) {
            if (abs(b - c) == 2)
            {
                cout << "YES" << endl;
            }
        }
        else if (b == 5) {
            if (abs(a - c) == 2)
            {
                cout << "YES" << endl;
            }
        }
        else if (c == 5) {
            if (abs(a - b) == 2)
            {
                cout << "YES" << endl;
            }
        }
        else {
            cout << "NO" << endl;
        }
    }
    else {
        cout << "NO" << endl;
    }

  
    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.length()-1;++i){
    for(int j=i+1;j<s.length();++j){
      if(s[j-1]<s[j]) swap(s[j-1],s[j]);
    }
  }
  int cnt=0;
  for(int i=1;i<s.size();++i)
    if(s[i-1]==s[i]) ++cnt;
  cout<<(cnt?"no":"yes")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    int ans;
    for(int i=0;i<=10;i++){
        ans=1000*i-n;
        if(ans>=0){
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    vector<long ll> vec(n);
    rep(i, n) cin >> vec[i];

    vector<long ll> ans(n);

    ll tmp = 0;

    rep(i,n){
        if(i == 0){
            tmp = vec[0]*2;
        }else{
            tmp = vec[i]*2 - tmp;
        }
    }

    tmp = tmp / 2;
    rep(i,n){
        if(i == 0){
            cout << tmp << " ";
        }else{
            cout << vec[i - 1] * 2 - tmp << " ";
            tmp = vec[i - 1] * 2 - tmp;
        }
    }
    cout << endl;
    
}

Measured memory_bytes: 2944
#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> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>a(m);
    vector<ll>dp(n,-1);
    rep(i,m){
        cin>>a[i];
        dp[a[i]-1]=0;
    }



if(dp[1]==-1&&dp[0]==-1)dp[1]=2;
if(dp[0]==-1)dp[0]=1;
if(dp[0]==0&&dp[1]==-1)dp[1]=1;
rep(i,n-2){
    if(dp[i+2]==0)continue;
    dp[i+2]=(dp[i+1]+dp[i])%1000000007;
}
cout<<dp[n-1];
return 0;

}

Measured memory_bytes: 4336
N = int(input())
a = [ int(x) for x in input().split(" ")]
a.sort()
ans = 1
for x in a:
  if x==10**18 and ans>1:
    ans = -1
    break
  else:
    ans *= x
    if ans>10**18:
      ans = -1
      break
print(ans)


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

int main() {
  vector<int> X(5,0);
  vector<int> Y(5,0);
  int min_mod = 10;
  int min_index = 0;
  for (int i=0; i<5; ++i) {
    cin >> X[i];
    int temp = X[i] % 10;
    if (temp == 0) {
      Y[i] = X[i];
    } else {
      Y[i] = X[i] - temp + 10;
      if (temp < min_mod) {
        min_index = i;
        min_mod = temp;
      }
    }
  }
  int ans = 0;
  for (int i=0; i<5; ++i) {
    ans += (i == min_index) ? X[i] : Y[i];
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{
	//2.すごろく	
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A;
		if (A == 1)
		{
			if (A == _A)
			{
				A_count[k]++;
			}
			else
			{
				k++;
				A_count[k] = 2;
			}
		}
		_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long lint;

int main() {
    int N, K;
    cin >> N >> K;
    lint ans = 0;
    // 全部 K の倍数
    {
        lint tmp = N/K;
        ans += tmp*tmp*tmp;
    }
    // 全部 aK + K/2
    if (K % 2 == 0) {
        lint tmp = (N + K/2) / K;
        ans += tmp*tmp*tmp;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long A, long double B){
    cout << (ll)floor((long double)A * (long double)B) << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3836