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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  int ret = 1;
  VI ans, v;
  int idx = INF;
  REP(i, n) {
    if(a[i] == 2) ans.PB(i), ret *= 2;
    if(a[i] == -2) v.PB(i);
    if(a[i] == -1) chmin(idx, i);
  }

  if(v.size()%2 == 0) {
    for(int i: v) ans.PB(i), ret *= 2;
  } else if(idx != INF) {
    for(int i: v) ans.PB(i), ret *= 2;
    ans.PB(idx);
  } else {
    REP(i, v.size()-1) ans.PB(v[i]), ret *= 2;
  }

  cout << ans.size() << endl;
  sort(ALL(ans));
  REP(i, ans.size()) cout << ans[i]+1 << endl;

  return 0;
}



Measured memory_bytes: 3224
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int N, M;
static bool connected[8][8] = {false};
static int count[8][256];

static int
solve_r(int cur, int state)
{
  int c = count[cur][state];
  if (c != 0)
  {
    c--;
  }
  else
  {
    if (state == 0)
    {
      c = 1;
    }
    else
    {
      c = 0;
      for (int next = 0, bit = 1; next < N; next++, bit <<= 1)
      {
        if (connected[cur][next] && (state & bit) != 0)
        {
          c += solve_r(next, state & ~bit);
        }
      }
    }
    count[cur][state] = c + 1;
  }
  return c;
}

static int
solve()
{
  return solve_r(0, (1 << N) - 2);
}

int
main()
{
  cin >> N >> M;
  for (int m = 0; m < M; m++)
  {
    int a, b;
    cin >> a >> b;
    a--; b--;
    connected[a][b] = true;
    connected[b][a] = true;
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int counter = 0;
		
		
		for(int i = a;i <= b;i++) {
			if(c % i == 0) {
				counter = counter + 1;
				
						
			}
		}
		
		System.out.println(counter);
		

		
				
	}
}


Measured memory_bytes: 26280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxh = 110;

char m[maxh][maxh];

int A, B;
int h = 0, w = 100;
char c1, c2;

void output() {
    printf("%d %d\n", h, w);
    for (int i = 1; i <= h; i++) puts(m[i]+1);
}

int main () {
    scanf("%d%d", &A, &B);
    if (A == 1 && B == 1) {
        ++h;
        for (int i = 1; i <= w; i++) {
            if (i == 1) {
                m[h][i] = '#';
            } else m[h][i] = '.';
        }
    } else {
        c1 = '.'; c2 = '#';
        if (A == 1 && B > 1) {swap(A, B); swap(c1, c2);}
        ++ h;
        for (int i = 1; i <= w; i++) m[h][i] = c2;
        -- A; --B;
        int t = A/49, y = A%49;
        while (t--) {
            ++h;
            for (int i = 2; i <= w; i+=2) {
                if ((i/2) <= 49) m[h][i] = c1;
            }
            for (int i = 1; i <= w; i++) {
                if (!m[h][i]) m[h][i] = c2;
            }
            ++ h;
            for (int i = 1; i <= w; i++) m[h][i] = c2;
        }
        {
            ++h;
            for (int i = 2; i <= w; i+=2) {
                if ((i/2) <= y) m[h][i] = c1;
            }
            for (int i = 1; i <= w; i++) {
                if (!m[h][i]) m[h][i] = c2;
            }
            ++ h;
            for (int i = 1; i <= w; i++) m[h][i] = c2;
        }
        int tmp = h+2;
        while (h < 100) {
            ++ h;
            for (int i = 1; i <= w; i++) m[h][i] = c1;
        }
        for (int k = 0; k < B; k++) {
            m[tmp+2*(k/50)][2*(k%50)+1] = c2;
        }
    }
    output();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;
 
const int MAXANS = 46;
const int MAXN = 100000 + 10;

int N;
int dp[MAXANS][MAXN];
int q1[MAXANS * MAXN], q2[MAXANS * MAXN];

void Work()
{
	scanf("%d", &N);
	int tail = 0;
	for (int i = 1; i <= 9; i ++)
	{
		dp[i][i % N] = 1;
		q1[tail] = i;
		q2[tail] = i % N;
		tail ++;
	}
	int Ans = 10000000;
	for (int h = 0; h < tail; h ++)
	{
		int i = q1[h];
		int md = q2[h];
		if (md == 0)
			Ans = min(Ans, i);
		for (int num = 0; num <= 9; num ++)
		{
			int ni = i + num;
			int nmd = (md * 10 + num) % N;
			if (ni < MAXANS)
			{
				if (dp[ni][nmd] == 0)
				{
					dp[ni][nmd] = 1;
					q1[tail] = ni;
					q2[tail] = nmd;
					tail ++;
				}
			}
		}
	}
	printf("%d\n", Ans);
}
 
int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 54144
#include <stdio.h>

int main(void)
{
  char ss[4], tt[4];
  scanf("%s %s", &ss, &tt);
  int ans = 0;
  for(int ii = 0;ii < 3;ii++)
  {
    if(ss[ii] == tt[ii])
    {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>

using namespace std;

int main(){
	long long n;
	cin >> n;
	vector<long long> a(n);
	vector<bool> check(n,false);
	
	for(long long i=0;i<n;i++){
		cin >> a[i];
	}
	
	long long now=0,cnt=0;
    while(1){
    	cnt++;
    	if(check[now]==false){
    		check[now]=true;
    	}else{
    		cout << "-1" << endl;
    		return 0;
    	}
    	
    	if(a[now]==2){
    		cout << cnt << endl;
    		return 0;
    	}
    	now=a[now]-1;
    }
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[3];
	for(int i=1;i<=2;i++)
	{
	cin>>a[i];
	if(a[i]=='A')
	a[i]=1;
	if(a[i]=='B')
	a[i]=2;
	if(a[i]=='C')
	a[i]=3;
	if(a[i]=='D')
	a[i]=4;
	if(a[i]=='E')
	a[i]=5;
	if(a[i]=='F')
	a[i]=6;
}
	if(a[1]>a[2])
	cout<<">"<<endl;
	if(a[1]==a[2])
	cout<<"="<<endl;
	if(a[1]<a[2])
	cout<<"<"<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int diff = 0;
    for (int i=1; i<=n; i++) {
        int num;
        cin >> num;
        if (i != num) diff++;
    }
    if (diff == 0 || diff == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, 0, s.size()) cout << "x";
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int mark[100005],a[100005];
int main()
{
	int N,i,x,c=0;
	cin>>N;
	for(i=1;i<=N;i++)
	cin>>a[i];
	x=1; 
	c=0;
	mark[1]=1;
	while(x!=2)
	{
		c++;
		x=a[x];
		if(mark[x])
		break;
		mark[x]=1;
	}
	if(x==2)
	cout<<c<<endl;
	else
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_V 100
#define min(a, b) ((a) < (b) ? (a) : (b))

const int INF = 100000000;
int cost[MAX_V][MAX_V];
int V;

void
dijkstra()
{
	int d[MAX_V];
	bool used[MAX_V];
	int u, v;
	int i;

	for (i = 0; i < V; ++i)
	{
		d[i] = INF;
		used[i] = false;
	}

	d[0] = 0;
	while (true)
	{
		v = -1;
		int mincost = INF;
		for (u = 0; u < V; ++u)
		{
			if (!used[u] && d[u] < mincost)
			{
				mincost = d[u];
				v = u;
			}
		}

		if (v == -1)
			break;

		used[v] = true;
		for (u = 0; u < V; ++u)
			d[u] = min(d[u], d[v] + cost[v][u]);
	}

	for (v = 0; v < V; ++v)
		printf("%d %d\n", v, d[v]);
}

int
main(int argc, char** argv)
{
	int u, v;
	int c;
	int k;
	int i, j;

	scanf("%d", &V);
	for (i = 0; i < V; ++i)
	{
		scanf("%d", &v);
		for (u = 0; u < V; ++u)
			cost[v][u] = INF;

		scanf("%d", &k);
		for (j = 0; j < k; ++j)
		{
			scanf("%d %d", &u, &c);
			cost[v][u] = c;
		}
	}

	dijkstra();
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
const long long inf=1000000000000000000;
long long f[200010][5];
int n;
long long a[200010];
long long pan(int x)
{
	if (x==0) return 2; else if (x&1) return 1; else return 0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=0;i<=n;i++) 
	for (int j=0;j<5;j++) f[i][j]=inf;
	f[0][0]=0;
	for (int i=1;i<=n;i++) 
	{
		f[i][0]=f[i-1][0]+a[i];
	    f[i][1]=min(f[i-1][0],f[i-1][1])+pan(a[i]);
	    f[i][2]=min(min(f[i-1][0],f[i-1][1]),f[i-1][2])+(1-(a[i]%2));
	    f[i][3]=min(f[i-1][2],f[i-1][3])+pan(a[i]);
	    f[i][4]=min(min(f[i-1][2],f[i-1][3]),min(f[i-1][1],f[i-1][4]))+a[i];
	}
	cout << min(min(min(f[n][0],f[n][1]),min(f[n][2],f[n][3])),f[n][4]) << endl;
}

Measured memory_bytes: 9600
void main()
{
    int n = readln.chomp.to!int;
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    int[] p = readln.split.to!(int[]);

    int p1, p2, p3;
    foreach (x; p)
    {
        if (x <= a) ++p1;
        if (a + 1 <= x && x <= b) ++p2;
        if (x >= b + 1) ++p3;
    }

    min(p1, p2, p3).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;
const ll LINF = ll(1e18);
const ll MOD = ll(1e9+7);

int main(){
  int n, k;cin>>n>>k;
  string s;cin>>s;
  vector<int> cnt;char pre='*';int num=0;
  if(s[0]=='1')cnt.push_back(0);
  rep(i, n){
    if(s[i]==pre){
      num++;
    }else{
      if(i!=0)cnt.push_back(num);
      num=1;pre=s[i];
    }
  }
  cnt.push_back(num);
  int m = (int)cnt.size();
  rep(i, m-1){
    cnt[i+1]+=cnt[i];
  }
  int t = min(k, (m+1)/2);
  int l = -2;
  int r = 2*k-1;
  int ans;
  while(l<m){
    if(l==-2)ans=cnt[min(r, m-1)];
    else ans=max(ans, cnt[min(r, m-1)]-cnt[l]);
    l+=2;r+=2;
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

char c[26];

int main()
{
	string s;

	cin >> s;

	for( int i = 0; i < s.size(); i++ ) {
		c[s[i] - 'a']++;
	}
	int ans = 0;
	for( int i = 0; i < sizeof(c); i++ ) {
		if( c[i] > 1 ) {
			ans = 1;
			break;
		}
	}

	if( ans == 0 ) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
class WeightedUnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        # 親ノードとの重み
        self.diff_weight = [0 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        # 親ノードはまだ上書きしない
        root = self.find(self.par[x])
        self.diff_weight[x] += self.diff_weight[self.par[x]]
        self.par[x] = root
        return self.par[x]

    def weight(self, x):
        """ x 根に対する重みを返す """
        self.find(x)
        return self.diff_weight[x]

    def diff(self, x, y):
        """ x と y の差分をとる """
        return self.weight(y) - self.weight(x)

    def unite(self, x, y, w):
        """ ノード x の下にノード y をつける。辺の重みは、w """
        # ただし、実際には、x の根と y の 根をくっつけるので、補正
        w += self.weight(x); w -= self.weight(y)
        x = self.find(x); y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            # y の下に x をつけることになるので、重さは反転させる
            self.par[x] = y
            w = -w
            self.diff_weight[x] = w
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
            self.diff_weight[y] = w
        else:
            self.par[y] = x
            self.rank[x] += 1
            self.diff_weight[y] = w
            
N, M = map(int, input().split())
UF = WeightedUnionFind(N)
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    # これまでに入力されたものと等しくないか確認する
    if UF.find(L) == UF.find(R):
        if UF.diff(L, R) != D:
            print('No')
            break
    else:
        UF.unite(L, R, D)
else:
    print('Yes')

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

int main() {
    int64_t N;
    cin >> N;
    set<string> st;
    for (int64_t _ = 0; _ < N; _++) {
        string S;
        cin >> S;
        st.insert(S);
    }

    cout << st.size() << endl;
}

Measured memory_bytes: 19228
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cctype>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <iterator>

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define ps(ch) printf("%s",ch)
#define NL printf("\n")
#define debug(x) printf("wow %d !!\n",x)

typedef long long LL;

using namespace std;

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

int main()
{
    LL a,b;
    while(sll(a,b)!=EOF)
    {
        LL g = gcd(a,b);
        LL l = a*b/g;
        printf("%lld %lld\n",g,l);
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		Integer v[]=new Integer[3];
		for(int i=0; i<3; i++) v[i]=sc.nextInt();
		Arrays.sort(v, (x,y)->Integer.compare(y, x));

		int cnt=0;
		cnt += v[0]-v[1];
		v[1]+=cnt;
		v[2]+=cnt;
		if((v[0]-v[2])%2==0) {
			cnt +=(v[0]-v[2]+1)/2;
		} else {
			cnt +=(v[0]-v[2]+1)/2+1;
		}
		System.out.println(cnt);

		sc.close();
	}
}


Measured memory_bytes: 26452
<?php
fscanf(STDIN, "%s", $S);
$n = strlen($S);
$dp[0][''] = 0;
for ($i = 0; $i < $n; $i++) {
  $c1 = $c2 = '';
  // 1文字取る
  $c1 = substr($S, $i, 1);
  foreach ($dp[$i] as $k => $v) {
      if ($k !== $c1) {
          if (!isset($dp[$i + 1][$c1])) {
            $dp[$i + 1][$c1] = $v + 1;
          } else {
            $dp[$i + 1][$c1] = max($dp[$i + 1][$c1], $v + 1);
          }
      }
  }
  if ($i > 0) {
    // 2文字取る
    $c2 = substr($S, $i - 1, 2);
    foreach ($dp[$i - 1] as $k => $v) {
      if ($k !== $c2) {
        if (!isset($dp[$i + 1][$c2])) {
          $dp[$i + 1][$c2] = $v + 1;
        } else {
          $dp[$i + 1][$c2] = max($dp[$i + 1][$c2], $v + 1);
        }
      }
    }
  }
//   printf("1:%s 2:%s\n", $c1, $c2);
//   foreach ($dp[$i + 1] as $k => $v) {
//       printf("-> %s %d\n", $k, $v);
//   }
}
printf("%d", max($dp[$n]));


Measured memory_bytes: 98800
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k, ans = 0; cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < k; i++) ans += a[i];
	cout << ans;

	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
char s[105][105];
int main(){
	cin>>n>>m;
	n--;m--;
	for(int i=1;i<=50;i++){
		for(int j=1;j<=100;j++){
			if(i%2==0) s[i][j]='#';
			else{
				if(j%2==1 && n){
					s[i][j]='.';
					n--;
				}else{
					s[i][j]='#';
				}
			}
		}
	}
	for(int i=51;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(i%2==1) s[i][j]='.';
			else{
				if(j%2==1 && m){
					s[i][j]='#';
					m--;
				}else{
					s[i][j]='.';
				}
			}
		}
	}
	cout<<100<<" "<<100<<endl;
	for(int i=1;i<=100;i++){
		cout<<s[i]+1<<endl;
	}	
	return 0;
}
/*
#.#.#.
.#.#.#
#.#.#.
.#.#.#
*/

Measured memory_bytes: 256
s = list(input())
s.reverse()
r = [0 for _ in range(2019)]
p = 0
for i in range(len(s)):
    p += pow(10, i, 2019) * int(s[i])
    p %= 2019
    r[p] += 1
ans = 0
for i in r:
    if i >= 2:
        ans += ((i - 1) * i) // 2
ans += r[0]
print(ans)

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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, q; cin >> a >> b >> q;
	
	vector<ll> s(a);
	for (int i = 0; i < a; i++){
		cin >> s[i];
	}

	vector<ll> t(b);
	for (int i = 0; i < b; i++){
		cin >> t[i];
	}
	
	// sorting 
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	while(q--){
		ll x; cin >> x;
		
		auto itS = upper_bound(s.begin(), s.end(),x);
		auto itT = upper_bound(t.begin(),t.end(),x);
		
		// shrines and temples before and after x
		ll s1, t1, s2, t2;
		
		if (itS <= s.begin())s1 = s2 = s[0];
		else if (itS >= s.end()) s1 = s2 = s[a-1];
		else {
			s1 = *itS;
			s2 = *(itS-1);
		}
		if (itT <= t.begin()) t1 = t2 = t[0];
		else if (itT >= t.end()) t1 = t2 = t[b-1];
		else{
			t1 = *itT;
			t2 = *(itT-1);
		}
		
		ll ans1 = min(abs(s1-x)+abs(t1-s1),abs(t1-x)+abs(t1-s1));
		ll ans2 = min(abs(s1-x)+abs(t2-s1),abs(t2-x)+abs(t2-s1));
		ll ans3 = min(abs(s2-x)+abs(t1-s2),abs(t1-x)+abs(t1-s2));
		ll ans4 = min(abs(s2-x)+abs(t2-s2),abs(t2-x)+abs(t2-s2));
		
		ll ans = min({ans1, ans2, ans3, ans4});
		cout << ans << endl;
	}
}


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

int main(){
    int n;
    scanf("%d",&n);
    int a[n],i,cnt1=0,cnt2=0;
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            cnt1++;
            if(a[i]%3==0||a[i]%5==0) cnt2++;
        }
    }

    if(cnt1!=0&&cnt2!=0&&cnt1==cnt2) printf("APPROVED");
    else if(cnt1!=cnt2) printf("DENIED");
    else printf("APPROVED");


    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Judge{
	String ans;
	void doit(int a,int b){
		if(a > b){
			ans = " > ";
		}
		else if(a < b){
			ans = " < ";
		}
		else{
			ans = " == ";
		}
		System.out.println("a" + ans + "b");
	}
}

class Main{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		Judge cr = new Judge();
		cr.doit(a,b);
	}
}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=1e5+10, M=(ll)1e9+1 ;
const int mod = 1e9+7 ;
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// vl ed[N],g[N],in(N),vis(N,0),cost(N,0);
vl g[N],vis(N,0);
vl ans;
priority_queue<ll,vl,greater<ll>> pq;
void dfs(ll x){
    vis[x]=1;
    ans.pb(x);
    for(auto &it:g[x]){
        if(!vis[it])
            pq.push(it);
      }
}

int main(){
 ios_base::sync_with_stdio(0);
  ll t,x;
  cin >> t >> x;
  long double ans=(1.0*t)/x;
  cout << fixed << setprecision(6) << ans ;
  return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	string s=readString();
	int ans=0,num=0;
	for(auto c:s){
		if(c=='B')
			num++;
		else
			ans+=num;
	}
	print(ans);
}


Measured memory_bytes: 3068
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int T = sc.nextInt();
    int R = (N/X+1)*T;
    if(N%X==0){
      R=(N/X)*T;
    }
    System.out.println(R);
  }
}

Measured memory_bytes: 35672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
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; }


ll n, ans;

void dfs(ll x, ll a, ll b, ll c){
    if(x > n) return;
    if(a && b && c) ans++;
    dfs(x*10+3, 1, b, c);
    dfs(x*10+5, a, 1, c);
    dfs(x*10+7, a, b, 1);
}

int main(){
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
  int W, H, x, y, r;
 
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
 
    if((x + r <= W) && (x >= r) && (y + r <= H) && (y >= r)){
    printf("Yes\n");
    }
    else{
      printf("No\n");
    }
 
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD=1e9+7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int h,w;
	cin >> h >> w;
	vector<vector<int> > dp(h+1,vector<int>(w+1, 0));
	dp[0][0]=1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c=='.') {
				if (i) dp[i][j]+=dp[i-1][j];
				if (j) dp[i][j]+=dp[i][j-1];
				dp[i][j]%=MOD;
			}
		}
	}
	cout << dp[h-1][w-1] << "\n";

}

Measured memory_bytes: 7124
#include<iostream>
#include<algorithm>
using namespace std;
int n;
const int maxn = 2001;
long long a[maxn], p[maxn];
long long dp[maxn][maxn];
int cmp(int i, int j)
{
	return a[i] > a[j];
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		p[i] = i;
	}

	sort(p + 1, p + n + 1, cmp);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			int l = j + 1;
			int r = n - i + j;
			if (l - 1 >= 1)
				dp[l][r] = max(dp[l][r], dp[l - 1][r] + abs(a[p[i]] * (p[i] - l + 1)));
			if (r + 1 <= n)
				dp[l][r] = max(dp[l][r], dp[l][r + 1] + abs(a[p[i]] * (p[i] - r - 1)));
			//printf("%d %d    ", l, r);

		}

	}
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		//ans = max(ans, dp[i][i - 1]);
	ans = max(ans, dp[i][i] + abs(a[p[n]] * (p[n] - i)));
	//ans = max(ans, f[i][i] + b[n].v * abs(i - b[n].p));

	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int n,k,f=0,x;
  cin >> n >> k;
  
  for(int i=0;i < n;i++) {
    cin >> x;
    if (k <= x)
      f += 2*(x-k);
    else
      if (k < 2*x)
       f += 2*(k-x);
      else
       f += 2*x;
   }
  cout << f << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

int main(){
  int d;

  while (std::cin >> d) {
    int sum=0;
    for(int i=1;i<600/d;i++){
      sum+=d*i*d*i*d;
    }

    std::cout << sum << '\n';
  }

}



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

int main() {
	int n,m;
	cin>>n>>m;
    int a[m],b[m];
    int hoge[n+1]={};
    for(int i=0;i<m;i++){
    	cin>>a[i]>>b[i];
    	hoge[a[i]]++;
    	hoge[b[i]]++;
    }
    for(int i=1;i<n+1;i++){
    	cout<<hoge[i]<<endl;
    }
    
    //cout<<n<<m<<endl;
    /*for(int i=0;i<m;i++){
    	cout<<a[i]<<b[i]<<endl;
    }*/
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll dp[109][N], arr[N];

ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if (a < 0)
    a += MOD;
  return a;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k, x;
  cin >> n >> k;
  for (int i = 0; i <= n; ++i) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    memset(arr, 0, sizeof arr);
    for (int j = 0; j <= k; ++j)
      dp[i][j] = dp[i-1][j];
    for (int j = 0; j <= k; ++j) {
//      for (int l = min(x, k - j); l >= 1; --l)
//        dp[l + j] = add(dp[l + j], dp[j]);
      int L = 1 + j, R = min(x, k - j) + j, val = dp[i-1][j];
      if(L <= R && val)
        arr[L] = add(arr[L], val), arr[R + 1] = add(arr[R + 1], -val);
    }
    for (int j = 1; j <= k; ++j)
      arr[j] = add(arr[j], arr[j - 1]);
    for (int j = 0; j <= k; ++j)
      dp[i][j] = add(dp[i][j], arr[j]);

  }
  cout << dp[n][k];
  return 0;
}


Measured memory_bytes: 79360
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

char chocolate[10 + 5][1000 + 5];
int white[10 + 5][1000 + 5];

int H, W, K;

int get_white(int u, int d, int l, int r)
{
	return white[d][r] - white[d][l - 1] - white[u - 1][r] + white[u - 1][l - 1];
}

int solution()
{
	int ans = 2147483647;
	vector<int> h_cut;

	for (int i = 0; i < (1 << (H - 1)); ++i)
	{
		int cur_cut = 0;
		h_cut.clear();

		for (int j = 0; j < H - 1; ++j)
		{
			if (i & (1 << j))
			{
				h_cut.push_back(j + 1);
				cur_cut++;
			}
		}

		int last_w_cut = 0;

		for (int j = 1; j <= W; ++j)
		{
			bool valid = true;

			int before = 0;
			int k;
			for (k = 0; k < (int)h_cut.size(); ++k)
			{
				int get_cnt = get_white(before + 1, h_cut[k], last_w_cut + 1, j);
				if (get_cnt > K) valid = false;
				before = h_cut[k];
			}
			int get_cnt = get_white(before + 1, H, last_w_cut + 1, j);
			if (get_cnt > K) valid = false;
			
			if (!valid)
			{
				bool real_valid = true;
				
				int before = 0;
				for (k = 0; k < (int)h_cut.size(); ++k)
				{
					int get_cnt = get_white(before + 1, h_cut[k], j, j);
					if (get_cnt > K) real_valid = false;
					before = h_cut[k];
				}
				int get_cnt = get_white(before + 1, H, j, j);
				if (get_cnt > K) real_valid = false;

				if (!real_valid)
				{
					cur_cut = 2147483647;
					break;
				}
				else
				{
					cur_cut++;
					last_w_cut = j - 1;
				}
			}
		}

		if (cur_cut < ans) ans = cur_cut;
	}

	return ans;
}

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

	scanf("%d %d %d", &H, &W, &K);

	for (int i = 1; i <= H; ++i) scanf("%s", chocolate[i] + 1);
	
	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			white[i][j] = white[i - 1][j] + white[i][j - 1] - white[i - 1][j - 1];
			if (chocolate[i][j] == '1') white[i][j]++;
		}
	}

	printf("%d\n", solution());

	return 0;
}

Measured memory_bytes: 384
import math

n=int(input())
D={}
for _ in range(n):
    a,b=map(int, input().split())
    if a==0 and b==0:
        key=(0,0)
    elif a==0:
        key=(0,1)
    elif b==0:
        key=(1,0)
    else:
        if a<0:
            a=-a
            b=-b
        g=math.gcd(a, abs(b))
        key=(a//g, b//g)
    if key not in D:
        D[key]=0
    D[key]+=1

mod=10**9+7
ans=1
zz=0

for k1, v1 in D.items():
    if v1==0:
        continue
    if k1==(0,0):
        zz+=v1
        continue

    if k1[1]>0:
        k2=(k1[1], -k1[0])
    else:
        k2=(-k1[1], k1[0])

    if k2 not in D:
        ans=ans*pow(2, v1, mod)%mod
    else:
        v2=D[k2]
        m=(pow(2, v1, mod)+pow(2, v2, mod)-1)%mod
        ans=ans*m%mod
        D[k2]=0

print((ans+zz-1)%mod)


Measured memory_bytes: 121684
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 ) * } } ; }
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 , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
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 ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        n: u64,
    }

    let ans = (1..n + 1).filter(|x| x.to_string().len() % 2 == 1).count();

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v));
#define MP make_pair
#define X first
#define Y second

using namespace std;

const double EPS = 1e-8;

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

template<class T> inline T sq(T a){return a*a;}
template<class T> T gcd(T m, T n){return n?gcd(n, m%n):m;}

const int N = 100010;
int par[N];
int dw[N];

void init(int n){
	rep(i, n) par[i] = i, dw[i] = 0;
}

int find(int x){
	if(x == par[x]) return x;
	int p = find(par[x]);
	dw[x] += dw[par[x]];
	return par[x] = p;
}

bool same(int x, int y){
	return find(x) == find(y);
}

void unite(int x, int y, int d){
	int rx = find(x), ry = find(y);
	// dw[x] = w[x]-w[rx]
	// dw[y] = w[y]-w[ry]
	// dw[x]-dw[y] = (w[x]-w[y])-(w[rx]-w[ry])
	// dw[x]-dw[y] = -d-(w[rx]-w[ry]) ∵w[x]+d = w[y]
	// dw[x]-dw[y] = -d+dw[ry] ∵dw[ry] = w[ry]-w[rx]
	// dw[ry] = dw[x]-dw[y]+d
	dw[ry] = dw[x]-dw[y]+d;
	par[ry] = rx;
}

int main(){
	int n, m;
	while(cin >> n >> m, n|m){
		init(n);
		while(m--){
			char c;
			cin >> c;
			if(c == '!'){
				int a, b, w;
				cin >> a >> b >> w;
				a--, b--;
				unite(a, b, w);
			}else{
				int a, b;
				cin >> a >> b;
				a--, b--;
				if(!same(a, b)){
					cout << "UNKNOWN" << endl;
				}else{
					cout << dw[b]-dw[a] << endl;
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,s=1,j,i;
    cin>>a;
    if(a==1)
        cout<<"1"<<endl;
    else
    {
        for(i=1; i<=a; i++)
        {
            s=s*2;

            if(s>a)
                break;
            c=s;
        }


        cout<<c<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k,q = map(int,input().split())
D =list(map(int,input().split()))
for _ in range(q):
  n,x,m = map(int,input().split())
  DD = [(d-1)%m+1 for d in D]
  tmp = x; s = (n-1) // k
  for i, di in enumerate(DD):
    tmp += di*(s + int((n-1)%k > i))
  print(n-1-(tmp//m-x//m))

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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define lson node<<1
#define rson (node<<1)+1

const int maxn=1e6+10;
const ll mod=1e9+7;
const double pi=acos(-1);


int a[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        sint(a[i]);
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
        cout<<ans;
    return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int N; cin>>N;
    cout<<180*(N-2)<<endl;
}


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

// (1) true???????????\?????????????????????
	// (1.1) ???????????????????´????????????°sum???????????????
	// (1.2) ??????????????????????????????
	// (1.3) ?????????0???????????????????????´????????\?????????????????????
		// (1.3.1) ?????????????????????
	// (1.4) ??????????????????????????????????????°?????????1??????????????\?????????????????????
		// (1.4.1) ????±???¨??????1?????????char??????????????????
		// (1.4.2) char?????????????????????????????°?????????????????????
		// (1.4.3) ????¨?????????°sum????????°???????¶??????????????????????
	// (1.5) sum?????¨?????????

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

		while(true){
			int sum = 0;
			String num = br.readLine();

			if (num.equals("0")){
				break;
			}

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 24140
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a+b==15) cout<<'+';
    else if(a*b==15) cout<<'*';
    else cout<<'x';
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

struct Doubling {
  const int LOG;
  vector<vector<int> > table;

  Doubling(int sz, int64_t lim_t)
      : LOG(64 - __builtin_clzll(lim_t)) {  // countl_zero()
    table.assign(LOG, vector<int>(sz, -1));
  }

  void set_next(int k, int x) { table[0][k] = x; }

  void build() {
    for (int k = 0; k + 1 < LOG; k++) {
      for (int i = 0; i < table[k].size(); i++) {
        if (table[k][i] == -1)
          table[k + 1][i] = -1;
        else
          table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }

  int query(int k, int64_t t) {
    for (int i = LOG - 1; i >= 0; i--) {
      if ((t >> i) & 1) k = table[i][k];
    }
    return k;
  }
};

void solve() {
  string s;
  cin >> s;
  const int n = s.size();

  Doubling db(n, 1e5);

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      db.set_next(i, i + 1);
    } else {
      db.set_next(i, i - 1);
    }
  }

  db.build();

  vector<int> sum(n);
  for (int i = 0; i < n; i++) {
    ++sum[db.query(i, 1e5)];
  }

  for (int i = 0; i < n - 1; i++) {
    cout << sum[i] << ' ';
  }
  cout << sum[n - 1] << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 7624
#include<stdio.h>
int main()
{
    char s[200005],S[200005];
    int l,i,count=0;
    scanf("%s",&s);
    scanf("%s",&S);
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(S[i]!=s[i])
            count++;
    }printf("%d\n",count);
    return 0;

}


Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int num[n];
    fill(num, num + n, 0);
    rep(i, n-1) {
        cin >> a[i];
        a[i]--;
        num[a[i]]++;
    }

    rep(i, n) cout << num[i] << endl;
}


Measured memory_bytes: 5184
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int []array=new int[N];
        for(int i=0;i<N;i++)array[i]=sc.nextInt();
        int num=0;
        for(int i=0;i<N;i++){
            int minj=i;
            for(int j=i;j<N;j++){
                if(array[minj]>array[j]){
                    minj=j;
                }
            }
            if(array[minj]!=array[i]){
            int tmp=array[minj];
            array[minj]=array[i];
            array[i]=tmp;
            num++;
           }
        }
        for(int i=0;i<N;i++){
            System.out.print(array[i]);
            if(i<N-1)System.out.print(" ");
        }
        System.out.println();
        System.out.println(num);
    }
}


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PF push_front
#define PB push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())
#define ALL(v) (v).begin(), (v).end()

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in() {int x; std::cin >> x; return x;}
 
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

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

int cnt[26];
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  string str;
  bool flg = true;
  cin >> str;

  REP(i, sz(str)) cnt[str[i] - 'a']++;
  REP(i, 26) if (cnt[i] % 2) flg = false;

  if (flg) print("Yes");
  else print("No");

  return (0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
int sum1[1000];
int sum2[1000];
int ans[1000];
int a[1000];
int main()
{
    int n,sum=0,minn=1000000;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=i; j++)
        {
            sum1[i]+=a[j];
        }
    }
    for(int i=1; i<=n; i++)
    {
        sum2[i]=sum-sum1[i];
    }
    for(int i=1; i<=n; i++)
    {
        ans[i]=abs(sum1[i]-sum2[i]);
        if(ans[i]<minn)
        {
            minn=ans[i];
        }
    }
    printf("%d\n",minn);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
mod = 10**9+7

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    facs = [1] * (n+1)
    invs = [1] * (n+1)
    nfac = 1
    for i in range(1, n+1):
        nfac = nfac * i % mod
        facs[i] = nfac
        invs[i] = pow(facs[i], mod-2, mod)

    d = 0
    comb = 1
    p = 1
    for i in range(0, n):
        # nCi
        comb = facs[n] * invs[i] * invs[n-i]%mod
        d = (d + comb*p%mod) % mod
        p *= 8
        p %= mod

    # {1~8}のみで構成されるパターン
    diff = (pow(10, n, mod) - pow(8, n, mod)) % mod
    diff = (diff - (2*d%mod)) % mod
    print(diff)


Measured memory_bytes: 98768
import java.util.*
import java.util.zip.Inflater

const val INF = 1000000000

class Node(val num: Int) {
    val adj = mutableListOf<Node>()
    var dMod = mutableListOf(INF, INF, INF)

    fun adjAdd(v: Node) {
        adj.add(v)
    }
}

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val graph = mutableListOf(Node(0))
    for (i in 1 until n + 1) graph.add(Node(i))
    for (j in 0 until m) {
        val (u, v) = readLine()!!.split(" ").map(String::toInt)
        graph[u].adjAdd(graph[v])
    }

    val (s, t) = readLine()!!.split(" ").map(String::toInt)
    graph[s].dMod[0] = 0
    var depth = 1
    var queue = ArrayDeque(listOf(graph[s]))
    do {
        val nextQueue = ArrayDeque<Node>()
        while (queue.size > 0) {
            val v = queue.poll()
            v.adj.forEach {
                if (it.num == t && depth % 3 == 0) {
                    println(depth / 3)
                    return
                }
                if (it.dMod[depth % 3] > depth) {
                    it.dMod[depth % 3] = depth
                    nextQueue.add(it)
                }
            }
        }
        queue = nextQueue
        depth++
    } while (queue.size > 0)
    println(-1)
}


Measured memory_bytes: 110764