akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b;
	cin >> a >> b;
	char result[101][101];
	for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			result[i][j] = '.';
		}
	}
	for(int i = 50; i < 100; i++){
		for(int j = 0; j < 100; j++){
			result[i][j] = '#';
		}
	}
	a--;
	b--;
	int nowi = 0, nowj = 0;
	while(b > 0){
		result[nowi][nowj] = '#';
		b--;
		if (nowj + 2 >= 100){
			nowi += 2;
			nowj = 0;
		} else {
			nowj += 2;
		}
	}
	nowi = 51, nowj = 0;
	while(a > 0){
		result[nowi][nowj] = '.';
		a--;
		if (nowj + 2 >= 100){
			nowi += 2;
			nowj = 0;
		} else {
			nowj += 2;
		}
	}
	cout << 100 << " " << 100 << endl;
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			cout << result[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	int m=0, nextm=0,cnt=0;
	rep(i,n){
		if(m < a[i]){
			m = a[i];
			cnt = i;
		}
	}
	rep(i,n){
		if(i == cnt) continue;
		nextm = max(nextm, a[i]);
	}
	vector<int> ans(n);
	rep(i,n){
		if(i==cnt) ans[i]=nextm;
		else ans[i]=m;
	}
	rep(i,n) cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = cin.next();
            }

            var set = new HashSet<string>();
            for (int i = 0; i < n; i++)
            {
                set.Add(s[i]);
            }

            Console.WriteLine(set.Count());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

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

  sort(A, A + 3);
  cout << (A[1] - A[0]) + (A[2] - A[1]) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static boolean avairable(int[] as, int min, int max) {
		switch(max-min) {
		case 0:
			for(int i=0; i<as.length; i++)
				if(as[i]!=as.length-1&&2*as[i]>as.length)
					return false;
			return true;
		case 1:
			int alone_num=0;
			for(int a: as)
				if(a==min)
					alone_num++;
			return alone_num<max && 2*(max-alone_num)<=as.length-alone_num;
		default:
			return false;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] as = new int[n];
		int min = n;
		int max = 0;
		for(int i=0; i<n; i++) {
			as[i] = sc.nextInt();
			if(as[i]<min) min = as[i];
			if(as[i]>max) max = as[i];
		}
		sc.close();

		System.out.println(avairable(as, min, max)?"Yes":"No");
	}
}


Measured memory_bytes: 50724
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))
N = int(input())
num = []
for i in range(N):
    num.append(int(input()))
bingo = {
    1:0,
    2:0,
    3:0,
    4:0,
    5:0,
    6:0,
    7:0,
    8:0,
    9:0
}
for i in range(len(A)):
    if A[i] in num:
        bingo[i+1] = 1
for i in range(len(B)):
    if B[i] in num:
        bingo[i+4] = 1
for i in range(len(C)):
    if C[i] in num:
        bingo[i+7] = 1
        
if bingo[1] == 1 and bingo[2] == 1 and bingo[3] == 1:
    ans = 'Yes'
elif bingo[4] == 1 and bingo[5] == 1 and bingo[6] == 1:
    ans = 'Yes'
elif bingo[7] == 1 and bingo[8] == 1 and bingo[9] == 1:
    ans = 'Yes'

elif bingo[1] == 1 and bingo[4] == 1 and bingo[7] == 1:
    ans = 'Yes'
elif bingo[2] == 1 and bingo[5] == 1 and bingo[8] == 1:
    ans = 'Yes'
elif bingo[3] == 1 and bingo[6] == 1 and bingo[9] == 1:
    ans = 'Yes'

elif bingo[1] == 1 and bingo[5] == 1 and bingo[9] == 1:
    ans = 'Yes'
elif bingo[3] == 1 and bingo[5] == 1 and bingo[7] == 1:
    ans = 'Yes'

else:
    ans = 'No'
print(ans)

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Edge {
	int v;
	string lab;
};

int n, a, s, g;
vector< vector< Edge > > adj;

string minimum_str = "{", spell[41][333];

void solve() {
	for_(i,0,n) for_(len,0,333) spell[i][len] = minimum_str;
	
	spell[s][0] = "";
	
	for_(len,0,333) for_(v,0,n) {
		if (spell[v][len] == minimum_str) continue;
		
		for (Edge e : adj[v]) {
			string add = e.lab;
			
			if (spell[e.v][len + add.size()] > spell[v][len] + add) {
				spell[e.v][len + add.size()] = spell[v][len] + add;
			}
		}
	}
	
	string ans = minimum_str;
	for_(len,1,333) ans = min(ans, spell[g][len]);
	
	if (ans == minimum_str || ans.size() > 240) cout << "NO" << endl;
	else cout << ans << endl;
}

int main() {
	while (cin >> n >> a >> s >> g, n) {	
		adj.assign(n, vector< Edge >());
	
		for_(i,0,a) {
			int x, y;
			string lab;
			cin >> x >> y >> lab;
			adj[x].push_back(Edge{y, lab});
		}
	
		solve();
	}
}

Measured memory_bytes: 7544
n,m = map(int,input().split())
count = 0
if m >= 2*n: #ex)3,6 4,15
    m -= 2*n
    count = n+(m//4)
#elif n <= m:  #ex)3,3 3,4 ,5 8
#    count = m//2
else:
    count = m//2
print(count)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll a;
  cin>>a;
  ll ans=abs(x-a);
  rep(i,n-1){
    ll b;
    cin>>b;
    ans=gcd(ans,abs(x-b));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            int h = x / (60 * 60);
            x -= h * 60 * 60;
            int m = x / 60;
            x -= m * 60;
            int s = x;

            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}



Measured memory_bytes: 18008
local mma = math.max
local n, k = io.read("*n", "*n")
local edge = {}
local len = {}
local childcnt = {}
local parent = {}
for i = 1, n do
  edge[i] = {}
  len[i] = -1
  childcnt[i] = 0
  parent[i] = 0
end
len[1] = 0
local ret = io.read("*n") == 1 and 0 or 1
for i = 2, n do
  local a = io.read("*n")
  table.insert(edge[a], i)
  table.insert(edge[i], a)
end
local tasks = {1}
for it = 1, n do
  local src = tasks[it]
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if len[dst] == -1 then
      len[dst] = len[src] + 1
      table.insert(tasks, dst)
      childcnt[src] = childcnt[src] + 1
      parent[dst] = src
    end
  end
end
local maxlen = {}
tasks = {}
for i = 1, n do
  maxlen[i] = len[i]
  if childcnt[i] == 0 then
    table.insert(tasks, i)
  end
end
for i = 1, n - 1 do
  local c = tasks[i]
  local p = parent[c]
  if k < maxlen[c] then
    if maxlen[c] - len[c] == k - 1 then
      ret = ret + 1
    else
      maxlen[p] = mma(maxlen[p], maxlen[c])
    end
  else
    maxlen[p] = mma(maxlen[p], maxlen[c])
  end
  childcnt[p] = childcnt[p] - 1
  if childcnt[p] == 0 then
    table.insert(tasks, p)
  end
end
print(ret)


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
int N,M;

int main(void){
  cin >> N >> M;
  int K[N];
  int A[N][M];
  int i,j,k,num=0;
  bool all,one;
  for(i=0;i<N;i++){
    cin >> K[i];
    for(j=0;j<K[i];j++){
      cin >> A[i][j];
    }
  }
  for(k=1;k<=M;k++){
    all = true;
    for(i=0;i<N;i++){
      one = false;
      for(j=0;j<K[i];j++){
        if(k == A[i][j]){
         one = true;
         break;
        }
      }
      if(!one){
        all = false;
        break;
      }
    }
    if(all){
      num++;
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	string S;
	int cnt=0;
	cin >> S;
	rep(i,0,S.size()){
		if(S[i] == 'o'){
			cnt++;
		}
	}
	if(cnt+15-S.size()>7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    var robots = ArrayBuffer[(Long, Long)]()
    for (i <- 0 until n) {
      val x = sc.nextLong
      val l = sc.nextLong
      robots.+=((x, l))
    }
    robots = robots.sortBy(_._1)

    var robotCount = n
    var before = robots(0)
    for (i <- 1 until n) {
      val beforeMax: Long = before._1 + before._2
      val currentMin: Long = robots(i)._1 - robots(i)._2
      val currentMax: Long = robots(i)._1 + robots(i)._2
      if (beforeMax > currentMin) {
        robotCount -= 1
        if (beforeMax > currentMax) {
          before = robots(i)
        }
      } else {
        before = robots(i)
      }
    }
    println(robotCount)
  }

}


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

    int ans;
    int v[1000000] = {0};
    v[s]++;
    for(int i=1; ; i++){
        if(s%2==0){
            s /= 2;
        }
        else{
            s = 3*s + 1;
        }

        if(v[s] == 0)
            v[s]++;
        else{
            ans = i+1;
            break;
        }
    }
    cout << ans;

    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main()
{
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    for(int i = 0; i < m; i++)
    {
        cin>>b[i];
    }
    
    bool ok = false;
    for(int y = 0; y < n-m+1; y++)
    {
        for(int x = 0; x < n-m+1; x++)
        {
            bool ok2 = true;                    
            for(int yy = 0; yy < m; yy++)
            {
                if(a[y+yy].substr(x,m) != b[yy])
                {
                    ok2 = false;
                    break;
                }
            }
            if(ok2) 
            {
                ok=true;
                break;
            }
        }
        if(ok)
        {
            break;
        }
    }

    if(ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        rep0(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c)pf("No");
    else if(a == b || b == c || a == c)pf("Yes");
    else pf("No");
    return 0;
}


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

vector<int> bfs(int cities, const vector<vector<int> > &connectionList) {
    vector<int> indices(cities);
    for (int city = 0, component = 1; city < cities; city++) {
        if (indices[city]) {
            continue;
        }
        indices[city] = component;
        queue<int> q;
        q.push(city);
        while (!q.empty()) {
            int curCity = q.front();
            q.pop();
            for (auto nextCity: connectionList[curCity]) {
                if (!indices[nextCity]) {
                    indices[nextCity] = component;
                    q.push(nextCity);
                }
            }
        }
        component++;
    }
    return indices;
}

vector<vector<int> > transformConnections(int cities, const vector<pair<int, int> > &connections) {
    vector<vector<int> > connectionList(cities);
    for (auto connection: connections) {
        connectionList[connection.first].push_back(connection.second);
        connectionList[connection.second].push_back(connection.first);
    }
    return connectionList;
}

vector<int> connectedCities(int cities, const vector<pair<int, int> > &roads, const vector<pair<int, int> > &rails) {
    vector<vector<int> > listRoads = transformConnections(cities, roads);
    vector<vector<int> > listRails = transformConnections(cities, rails);
    vector<int> indicesRoads = bfs(cities, listRoads);
    vector<int> indicesRails = bfs(cities, listRails);
    unordered_map<long long, int> pairIndices;
    for (int city = 0; city < cities; city++) {
        long long pairIndex = ((long long) indicesRoads[city]) * cities + indicesRails[city];
        pairIndices[pairIndex]++;
    }
    vector<int> result(cities);
    for (int city = 0; city < cities; city++) {
        long long pairIndex = ((long long) indicesRoads[city]) * cities + indicesRails[city];
        result[city] = pairIndices[pairIndex];
    }
    return result;
}

void solve() {
	int n, k, l;
	cin >> n >> k >> l;
	vector<pair<int, int> > roads(k), rails(l);
	for (auto &p: roads) {
		cin >> p.first >> p.second;
		p.first--;
		p.second--;
	}
	for (auto &p: rails) {
		cin >> p.first >> p.second;
		p.first--;
		p.second--;
	}
	vector<int> res = connectedCities(n, roads, rails);
	for (auto v: res) {
		cout << v << " ";
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	solve();
}


Measured memory_bytes: 26348
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);
  int a = -1;
  int b = -1;
  int i = 0;
  do {
    if (a < 0 && v == P) {
      a = i;
    }
    // N.B.: P could be equal to Q
    if (b < 0 && v == Q) {
      b = i;
    }
    ++i;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a - b) << endl;
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);

  rep(i, N)
  {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  vector<int> ans(2, 0);
  rep(i, N)
  {
    ans.at(i % 2) += a.at(i);
  }

  cout << ans.at(0) - ans.at(1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r,s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    s=0;
    for(i=0;i+1<n;)
    {
        if(a[i]>a[i+1])
        {
            m=LLONG_MAX;
            for(j=i+1;j<n;j++)
            {
                if(a[j]>a[i])
                {
                    break;
                }
                s+=a[i]-a[j];
            }
            i=j;
        }
        else
        {
            i++;
        }
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 5224
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {

		Scanner scaner = new Scanner( System.in );

		int time = Integer.parseInt( scaner.next() );
		final int HOUR = 3600;
		final int MINUTE = 60;

		int hour ;
		int minute ;
		int second  ;
		int remain;

		hour   = time / HOUR;
		remain = time % HOUR;

		minute = remain / MINUTE;
		remain = remain % MINUTE;

		second = remain;

		System.out.println( hour + ":" + minute + ":" + second );

		scaner.close();

	}

}

Measured memory_bytes: 25960
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	ll m[100000] = {};
	ll p[100] = {};
	ll x[100] = {};
	//ll *x, *c, *d;
	string S,T;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll max = 0;
	//char p;
	cin >> N;



	rep(i, 0, N) {
		cin >> x[i];
		max += x[i];
	}
	
	sort(x,x+N);

	if (max % 10 != 0) {
		cout << max << endl;
		return 0;
	}

	rep(i, 0, N) {
		
		if (x[i] % 10 != 0) {
			sum = x[i];
			count = 1;
		}

		if (count == 1) {
			break;
		}
		//cout << x[i] << endl;
	}

	if (count != 1)
		cout << 0 << endl;
	else
		cout << max - sum << endl;


	return 0;

}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    Vec v(n);
    ll ans=0;

    rep(i,n){
        cin>>v[i];
        if(v[i]>=k){
            ans++;
        }
    }

    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;

int main(){
    ll n,k,ans;
    ans=0;
    cin>>n>>k;
    for(ll i=k;i<=n+1;i++){
        ll num=i*(2*n-i+1)/2;
        num-=i*(i-1)/2;
        num+=1;
        ans+=num;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: cnt(0:101), x,n,i,l,r
    integer(int32), allocatable:: p(:)

    read*, x,n
    allocate(p(n))
    read*, p(:)
    cnt(:) = 0
    do i=1,n
        cnt(p(i))=cnt(p(i))+1
    end do

    l=x
    r=x

    do while(0 /= l .or. r /= 101)
        if (cnt(l) == 0) then
            print'(i0)', l 
            stop
        end if

        if (cnt(r) == 0) then
            print'(i0)', r
            stop
        end if

        l=max(l-1,0)
        r=min(r+1,101)
    end do
end program main

Measured memory_bytes: 2932
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    long L = scanner.nextLong();
    long R = scanner.nextLong();
    long min = 2018;
    
    if((R-L)<2019){
      for(long i=L; i<R; i++){
        for(long j=(i+1); j<=R; j++){
          if(min>i*j%2019){
            min = i*j%2019;
          }
        }
      }
    }else{
      min = 0;
    }
    System.out.println(min);
    
  }
}

Measured memory_bytes: 21844
n=int(input())
A=[1]*(n+1)
A[1]=1
for i in range(2,n+1):
    for j in range(i,n+1,i):
        A[j]+=1
A[1]=1
sum=0
for i in range(1,n+1):
    sum+=i*A[i]
print(sum)

Measured memory_bytes: 150524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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 namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep (i, N) cin >> a[i];
  int ans = (N - K) / (K - 1) + 1;
  if ((N - K) % (K - 1) != 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
n,x,y = map(int,input().split())
k = [0 for i in range(n)]
for i in range(n):
    for j in range(i,n):
        #print(i,j,j-i,abs(x-1-i)+abs(y-1-j)+1,abs(x-1-j)+abs(y-1-i)+1)
        dist = min(j-i,abs(x-1-i)+abs(y-1-j)+1,abs(x-1-j)+abs(y-1-i)+1)
        k[dist]+=1

for i in range(1,n):
    print(k[i])


Measured memory_bytes: 48092
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N,K; cin >> N >> K;
    long long ans = 0, t = N-K;
    ans += t*(t+1)/2;

    for(int i = K+1; i <= N-K; i++){
        long long c = N/i - 1;
        ans += (c*(i-K));
        if (N % i >= K){
            ans += (N%i - K + 1);
        }
    }
    if (K == 0) ans -= N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
       int n;
       cin>>n;
       vector<string> s(n);
       for(int i=0;i<n;i++)
       cin>>s[i];
       unordered_map<string,int> u;
       for(int i=0;i<n;i++)
       {
           u[s[i]]++;
       }
       cout<<"AC"<<" x "<<u["AC"]<<endl;
       cout<<"WA"<<" x "<<u["WA"]<<endl;
       cout<<"TLE"<<" x "<<u["TLE"]<<endl;
       cout<<"RE"<<" x "<<u["RE"]<<endl;
	}
	
}

Measured memory_bytes: 6276
list = []
count = 0
flag = True

while flag:
    h,w=input().split()
    list.append((int(h),int(w)))
    if list[count][0] == 0:
        flag = False
    count += 1


for i in range(len(list)):
    for j in range(list[i][0]):
        print("#",end="")
        for k in range(1,list[i][1]-1):
            if j== 0 or j==list[i][0]-1:
                print("#",end="")
            else:
                print(".",end="")
        print("#")
    if list[i][0] == 0:
        break
    print("")

"""

for i in range(1):
    for j in range(3):
        print("#",end="")
        for k in range(1,3):
            if j==0 or j==2:
                print("#",end="")
            else:
                print(".",end="")
        print("#")

    print("")
"""



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

int a[200005];

int main(int argc, char** argv)
{
	int k, n;
	scanf("%d%d", &k, &n);
	for(int i=0; i<n; i++) scanf("%d", a + i);
	int max = k - a[n - 1] + a[0];
	for(int i=1; i<n; i++)
	{
		int diff = a[i] - a[i - 1];
		if(diff > max) max = diff;
	}
	printf("%lld\n", k - max);
	return 0;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int ice[91][91];
int W, H;

int dfs( int sx, int sy, int d ) {
	int res = d;

	REP( i, 4 ) {
		int nx = sx + dx[i];
		int ny = sy + dy[i];
		
		if( nx >= 0 && nx < W && ny >= 0 && ny < H && ice[nx][ny] == 1 ) {
			ice[nx][ny] = 0;
			chmax( res, dfs( nx, ny, d + 1 ) );
			ice[nx][ny] = 1;
		}
	}

	return res;
}

signed main() {
	while( cin >> W >> H, W, H ) {
		REP( i, H ) {
			REP( j, W ) {
				cin >> ice[j][i];
			}
		}

		int ans = 0;
		REP( i, H ) {
			REP( j, W ) {
				if( ice[j][i] ) {
					ice[j][i] = 0;
					chmax( ans, dfs( j, i, 1 ) );
					ice[j][i] = 1;
				}
				
			}
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 3068
pub fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

const INF: usize = 10000;

fn main() {
    let n = read1::<usize>();
    let mut ab = (0..n).map(|_| readn::<usize>(" ")).collect::<Vec<Vec<usize>>>();
    let mut cd = (0..n).map(|_| readn::<usize>(" ")).collect::<Vec<Vec<usize>>>();
    ab.sort_by(|a, b| b[0].cmp(&a[0]));
    cd.sort_by(|a, b| a[1].cmp(&b[1]));
    let mut ans = 0;

    for i in 0..n {
        for j in 0..n {
            if ab[j][0] < cd[i][0] && ab[j][1] < cd[i][1] {
                ans += 1;
                ab[j] = vec![INF, INF];
                break;
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int b, f, r, v, i, j, k;
        int a[][][] = new int[4][3][10];
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(i = 0; i < 4; i++){
            for(j = 0; j < 3; j++){
                for(k = 0; k < 10; k++){
                    a[i][j][k] = 0;
        		}
        	}
        }
        for(i = 0; i < n; i++){
            b = scan.nextInt();
            f = scan.nextInt();
            r = scan.nextInt();
            v = scan.nextInt();
            if(b != 0){
                a[b - 1][f - 1][r - 1] += v;
                if(a[b - 1][f - 1][r - 1] < 0) a[b - 1][f - 1][r - 1] = 0;
            }
        }
        for(i = 0; i < 4; i++){
            for(j = 0; j < 3; j++){
                for(k = 0; k < 10; k++){
                    System.out.printf(" %d", a[i][j][k]);
                }
                System.out.print("\n");
        	}
            if(i != 3) System.out.printf("####################\n");
        }
    }
}



Measured memory_bytes: 30552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

vector<int> A;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
    ll n, m; cin >> n >> m;
    ll d = 0;
    for (int i = 0; i < n; ++i) {
        ll t;
        cin >> t;
        A.push_back(t);
        // if (t % 2 != 0 || t % 4 == 0) {
        //     cout << 0 << endl;
        //     return 0;
        // }
        d = i == 0 ? t / 2 : lcm(d, t / 2);
    }
    for (const int &x: A) {
        if (d % x == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << m / d / 2 + m / d % 2 << endl;
    return 0;
}


Measured memory_bytes: 892
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    final int MOD = 1000000007;
    public void solve() {
    	int H = ni();
    	int W = ni();
    	char[][] A = new char[H+10][W+10];
    	char[] wk;
    	for (int i = 0; i < H; i++) {
    		wk = ns().toCharArray();
    		for (int j = 0; j < W; j++) {
				A[i][j] = wk[j];
			}
		}
    	int[][] dp = new int[H][W];
    	dp[0][0] = 1;
    	for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if(A[i+1][j] == '.')
					dp[i+1][j] = (int)(((long)dp[i+1][j] + (long)dp[i][j]) % MOD);
				if(A[i][j+1] == '.')
					dp[i][j+1] = (int)(((long)dp[i][j+1] + (long)dp[i][j]) % MOD);
			}
		}
    	out.println(dp[H-1][W-1]);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 37284
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int a, p;

int main(){
    cin >> a >> p;
    cout << floor(((a*3) + p)/2);

}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};

/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }
    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }
        m = n;
        n = k;
    }
}

fn main() {
    input! {
        n: usize,
        av: [u64; n],
    }

    let mut iter = av.iter();
    let answer = iter
        .next()
        .map(|&base| iter.fold(base, |gcd_num, &a| gcd(gcd_num, a)))
        .unwrap();

    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

int main(){
    LL N,L;
    cin>>N>>L;
    deque<LL>dq;
    LL sum=0LL;
    LL a[100004];
    int pos=-1;
    REP(i,N){
        cin>>a[i];
        if(i!=0&&a[i-1]+a[i]>=L){
            pos=i;
        }
    }
    if(pos==-1){
        cout<<"Impossible"<<endl;return 0;
    }
    vector<LL>res;
    for(int i=1;i<pos;i++){
        res.PB(i);
    }
    for(int i=N-1;i>=pos;i--){
        res.PB(i);
    }
    
    cout<<"Possible"<<endl;
    REP(i,N-1){
        cout<<res[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2548
N = int(input())
A = list(map(int, input().split()))
A.reverse()
ans = "Yes"
for i in range(N-1):
  if A[i] >= A[i+1]:
    continue
  elif A[i] == A[i+1] - 1:
    A[i+1] = A[i]
  else:
    ans = "No"
print(ans)

Measured memory_bytes: 20672
#include <cmath>
#include <string>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(void){
    long int n, sum = 0;
    
    cin >> n;
    
    for( int i = 0; i <= n; i++ ){
        if( i % 3 != 0 && i % 5 != 0 ){
            sum += i;
        }
    }
    
    cout << sum << "\n";
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int x=max(a,max(b,c)),y=min(a,min(b,c));
    cout <<x-y<<endl;
    return 0;
}


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

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

    int L[N];
    int s = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
        s += L[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (s - L[i] <= L[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
local h, w = io.read("*n", "*n", "*l")
local map = {}
for i = 1, h do
  local s = io.read()
  for j = 1, w do
    map[(i - 1) * w + j] = s:sub(j, j) == "."
  end
end

local taskstate = {}
for i = 1, h * w do taskstate[i] = false end
local tasks = {}
local tasknum = 0
local done = 0
local tasklim = h * w

local function addtask(idx)
  if not taskstate[idx] then
    taskstate[idx] = true
    tasknum = tasknum + 1
    local taskidx = tasknum % tasklim
    if taskidx == 0 then taskidx = tasklim end
    tasks[taskidx] = idx
  end
end

local inf = 1000000007
local len = {}
for i = 1, h * w do
  len[i] = inf
end
if not map[1] then
  len[1] = 1
else
  len[1] = 0
end


local function walk(src, dst)
  if map[src] == map[dst] then
    if len[src] < len[dst] then
      len[dst] = len[src]
      addtask(dst)
    end
  else
    if len[src] + 1 < len[dst] then
      len[dst] = len[src] + 1
      addtask(dst)
    end
  end
end

addtask(1)

while done < tasknum do
  done = done + 1
  local taskidx = done % tasklim
  if taskidx == 0 then taskidx = tasklim end
  local idx = tasks[taskidx]
  taskstate[idx] = false

  if idx <= (h - 1) * w then walk(idx, idx + w) end
  if 1 < w then
    if idx % w ~= 0 then walk(idx, idx + 1) end
  end
end
local ret = len[h * w]
print(math.ceil(ret / 2))


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n, m;
    cin>>n>>m;
    lli ans = (n * (n - 1)) / 2;
    ans += ((m - 1) * m) / 2;
    cout<<ans;
    cout<<'\n';
    return ;
}



/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string t;
  cin>>t;
  int n=0;
  vector<int> x(t.size());
  for(int i=0;i<t.size();i++){
    if(t[i]=='?'){
     t[i]='D';
    }
  }
  cout<<t<<endl;
}

Measured memory_bytes: 4452
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
int n,a[200010],b[200010];
int mp[4010][4010],c[8010][4010];
ll ans;
int main()
{
	c[0][0]=1;
	for(int i=1;i<=8000;i++)
	{
		c[i][0]=1;
		int l=min(i,4000);
		for(int j=1;j<=l;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		++mp[a[i]+2000][b[i]+2000];
	}
	for(int i=4000;i>=0;i--)
		for(int j=4000;j>=0;j--)
			mp[i][j]=(mp[i+1][j]*1ll+mp[i][j+1]+mp[i][j])%MOD;
	for(int i=1;i<=n;i++)
		ans=(ans+mp[-a[i]+2000][-b[i]+2000]-c[2*(a[i]+b[i])][2*a[i]]+MOD)%MOD;
	ans=ans*500000004%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 188544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		Pattern p = Pattern.compile("^A?+KIHA?+BA?+RA?+$");

		if(p.matcher(input).matches()){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21204