akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
  int n;
  cin >> n;
  
  long long int ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= i + 1;
    if (ans > 1000000000 + 7) {
      ans %= 1000000000 + 7;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long __int64;
#define NOS (4000)

int main()
{
	const __int64 threshold = 1000000;
//	const __int64 NOS = 4000;
	int n;
	
	while (std::cin >> n, n) {
		std::vector<int> inputStaff(n);
		__int64 staff[NOS] = {0};
		
		while (n--) {
			int id;
			__int64 unit, quantity;
			std::cin >> id >> unit >> quantity;
			staff[id - 1] += unit * quantity;
			if (std::find(inputStaff.begin(), inputStaff.end(), id) == inputStaff.end()) inputStaff.push_back(id);
		}
		
		bool naFlag = true;
		std::vector<int>::iterator it = inputStaff.begin(), eit = inputStaff.end();
		for (; it != eit; ++it) {
			if (staff[*it - 1] >= threshold)  {
				naFlag = false;
				std::cout << *it << std::endl;
			}
		}
		if (naFlag) std::cout << "NA" << std::endl;
	}
	
	return 0;
}

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


int main(){long N, M;
cin >> N >> M;
vector<long> a(M + 1), b(M + 1);
erep(i, M) cin >> a.at(i) >> b.at(i);
vector<long> cnt(N + 1);
string ans = "IMPOSSIBLE";
erep(i, M){
    if(a.at(i) == 1){
        cnt.at(b.at(i))++;
        if(cnt.at(b.at(i)) == 2) ans = "POSSIBLE";
    }
    if(b.at(i) == N){
        cnt.at(a.at(i))++;
        if(cnt.at(a.at(i)) == 2) ans = "POSSIBLE";
    }
}



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

Measured memory_bytes: 4992
import java.util.Scanner;
//import java.util.Arrays;
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();
		System.out.println(c + " " + a + " " + b);
	}
}


Measured memory_bytes: 39524
#include<stdio.h>
int main(){

  int n,m,c;
  int i,k;
  scanf("%d%d%d",&n,&m,&c);

  int b[50];
  int a[50][50];
  int tmp[50]={};
  int count=0;

  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<n;i++){

    for(k=0;k<m;k++){
      scanf("%d",&a[i][k]);//i個目の要素数kの配列
    }

  }
  for(i=0;i<n;i++){

    for(k=0;k<m;k++){

      a[i][k]=a[i][k]*b[k];
    tmp[i]+=a[i][k];

    }
    tmp[i]+=c;

  }

  for(i=0;i<n;i++){
    if(tmp[i]>0){
      count++;
    }
  }

  printf("%d",count);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 0;

    ll cc = m / 2;
    ll norm_scc = min(n, cc);
    n -= norm_scc;
    m -= 2 * norm_scc;

    ans += norm_scc;

    ll cc4 = m / 4;
    ans += cc4;
    cout << ans << endl;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  string A,C;
  ll B=0;
  cin >> A;
  REP(i, A.size()){
    C = A[i];
     B += stoi(C);
  }
  if(B%9==0) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const int N = 300;
const db EPS = 1e-9;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int l,k;
ll dp[N][2], ans;

int main()
{
	scanf("%d%d",&l,&k);
	dp[1][0] = 1, dp[k][0] = 1;
	// 0-黑, 1-白
	rep(i,1,l){
		dp[i+1][0] += dp[i][1];
		dp[i+1][1] += dp[i][0];
		dp[i+k][0] += dp[i][1];
	}
	rep(i,1,l) ans += dp[i][0];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,c,k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    
    sort(t.begin(),t.end());
    ll ans=1,cnt=0,time=t[0];
    rep(i,n){
        if(cnt < c && t[i] - time <= k){
            cnt++;
        }
        else{
            cnt = 1; time= t[i]; ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


int getdepth(vector<int> &depth, vector<vector<int>> &edges){
    int n = edges.size();
    int husai = 0;
    depth[0] = 0;
    queue<pair<int,int>> q;
    q.push(make_pair(0, -1));
    int parent = -1;
    int accum_odd = 0;
    int accum_even = 0;
    int ret = 0;

    while(!q.empty()){
        auto t = q.front();
        q.pop();
        int now = t.first;
        int parent = t.second;

        if(depth[now]%2==0){
            ret += max(0LL, accum_odd - 1);
            accum_even++;
        }
        else{
            ret += max(0LL, accum_even-1);
            accum_odd++;
        }
        for(int e: edges[now]){
            if(e == parent)
                continue;
            else if(depth[e] != -1 && (depth[now] - depth[e])%2==0){
                return -1;
            }
            else if(depth[e] != -1 && depth[now] - depth[e] >= 1){
                husai++;
            }
            else if(depth[e] != -1 && depth[now] < depth[e])
                continue;
            else{
                depth[e] = depth[now] + 1;
                q.push(make_pair(e, now));
            }
        }
    }
    return ret - husai;
}

signed main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> depth(n, -1);

    int ret = getdepth(depth, edges);

    cout << (ret==-1?(n*(n-1)/2-m):ret) << endl;

    return 0;
}


Measured memory_bytes: 7424
using System;

namespace agc004A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long D = long.Parse(str[0]);
            long B = long.Parse(str[1]);
            long C = long.Parse(str[2]);
            long[] A = new long[] { D, B, C };
            Array.Sort(A);
            if (A[2] % 2 == 1)
                Console.WriteLine(A[0] * A[1] * 1);
            else
                Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11220
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",&x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int INF = 1e9;
const int mod = 2010;
const int maxn = 2e4 + 7;

bool check(char a,char b) {
    return a == '?' || b == '?' || a == b;
}

char s1[maxn],s2[maxn],s3[maxn];
int ab[maxn],bc[maxn],ac[maxn];

int main() {
    while(~scanf("%s %s %s",s1,s2,s3)) {
        int len1 = strlen(s1);
        int len2 = strlen(s2);
        int len3 = strlen(s3);
        mem(ab),mem(bc),mem(ac);
        rep(i,0,len1-1) {
            rep(j,0,len2-1) {
                if(!check(s1[i],s2[j])) {
                    ab[i-j+4000] = true;
                }
            }
            rep(j,0,len3-1) {
                if(!check(s1[i],s3[j])) {
                    ac[i-j+4000] = true;
                }
            }
        }
        rep(i,0,len2-1) {
            rep(j,0,len3-1) {
                if(!check(s2[i],s3[j])) {
                    bc[i-j+4000] = true;
                }
            }
        }
        int ans = INF;
        rep(i,-4000,4000) {
            rep(j,-4000,4000) {
                if(!ab[i+4000] && !ac[j+4000] && !bc[j-i+4000]) {
                    int l = min(0,min(i,j));
                    int r = max(len1,max(len2+i,len3+j));
                    ans = min(ans,r-l);
                }
            }
        }
        pd(ans);
    }
    return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int k = scanner.nextInt();
		List<Pair>[] list = new List[n];
		for (int i = 0; i < n; i++)
			list[i] = new ArrayList<Pair>();
		while (m-- > 0) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int l = scanner.nextInt();
			list[a].add(new Pair(b, l));
			list[b].add(new Pair(a, l));
		}
		int[] dp = new int[n];
		Arrays.fill(dp, 1 << 25);
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		for (int i = 0; i < k; i++) {
			int s = scanner.nextInt() - 1;
			dp[s] = 0;
			pq.offer(new Pair(0, s));
		}
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int f = pair.f;
			int s = pair.s;
			if (dp[s] < f)
				continue;
			for (Pair p : list[s]) {
				if (dp[p.f] <= f + p.s)
					continue;
				dp[p.f] = f + p.s;
				pq.offer(new Pair(f + p.s, p.f));
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (dp[i] == 0)
				continue;
			for (Pair p : list[i]) {
				int a = Math.max(dp[i], dp[p.f]);
				int b = a + (p.s - Math.abs(dp[i] - dp[p.f]) + 1) / 2;
				ans = Math.max(ans, b);
			}
		}
		System.out.println(ans);
	}

	class Pair implements Comparable<Pair> {
		int f, s;

		public Pair(int f, int s) {
			super();
			this.f = f;
			this.s = s;
		}

		@Override
		public String toString() {
			return "Pair [f=" + f + ", s=" + s + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return f - o.f;
		}

	}
}

Measured memory_bytes: 109180
def op(m, sum, b, c)
  return sum if !m.key?(b)
  b_ct, b_sum = m[b]
  c_ct, c_sum = (m[c] || [0, 0])
  m[c] = [b_ct + c_ct, c_sum + (b_ct * c)]
  m.delete(b)
  return sum - b_sum + (b_ct * c)
end

N = gets.to_i
AS = gets.split.map(&:to_i)

m = AS.group_by(&:itself).to_h{|k, a| [k, [a.length, a.length * k]]}
sum = m.values.map{_2}.sum

Q = gets.to_i
Q.times do
  b, c = gets.split.map(&:to_i)
  sum = op(m, sum, b, c)
  puts sum
end

Measured memory_bytes: 32044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    int a, b, c, k; cin >> a >> b >> c >> k;
    int ans = 0;
    int xa = 0, xb = 0, xc = 0;
    xa = min(a, k);
    k -= xa;
    xb = min(b, k);
    k -= xb;
    xc = min(c, k);
    ans = xa - xc;
    cout << ans << endl;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int main()
{
      long double a,b;
      cin>>a>>b;
      cout<<(ll)floor(a*b)<<endl;
}

Measured memory_bytes: 3732
N = int(input())
S = input()

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string::size_type pos = 0;
    while ((pos = s.find(",", pos)) != string::npos) {
        s.replace(pos, 1, " ");
        pos += 1;
    }
    cout << s << endl;
    return 0;
}

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

class Dice {
private:
    int num[6];
    int top;
    int side_n;
    int side_e;

public:
    Dice(int *num);
    void Roll(char dir);
    int getNum(char dir);
};

Dice::Dice(int *num)
{
    for (int i = 0; i < 6; i++) this->num[i] = num[i];
    top = 1;
    side_n = 5;
    side_e = 3;
}
int Dice::getNum(char dir)
{
    int pos;
    
    switch (dir) {
        case 'T': pos = top; break;
        case 'B': pos = 7 - top; break;
        case 'N': pos = side_n; break;
        case 'E': pos = side_e; break;
        case 'W': pos = 7 - side_e; break;
        case 'S': pos = 7 - side_n; break;
        default : break;
    }
    return num[pos-1];
}
void Dice::Roll(char dir)
{
    int tmp;
    
    switch (dir) {
        case 'N': tmp = top; top = 7-side_n; side_n = tmp; break;
        case 'E': tmp = top; top = 7-side_e; side_e = tmp; break;
        case 'W': tmp = top; top = side_e; side_e = 7-tmp; break;
        case 'S': tmp = top; top = side_n; side_n = 7-tmp; break;
        case 'R': tmp = side_n; side_n = 7-side_e; side_e = tmp; break;
        case 'L': tmp = side_e; side_e = 7-side_n; side_n = tmp; break;
        default : break;
    }
}

int main()
{
  int a[6];
  int n;
  int top, front;
  int count;
  
  for (int i = 0; i < 6; i++) cin >> a[i];
  Dice dice(a);
  cin >> n;
  for (int i = 0; i < n; i++) {
      cin >> top >> front;
      count = 0;
      while (dice.getNum('T') != top) {
          dice.Roll(count % 2 == 0 ? 'N' : 'E');
          count++;
      }
      count = 0;
      while (dice.getNum('S') != front) {
          dice.Roll('R');
          count++;
      }
      cout << dice.getNum('E') << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
N=int(input())
B=list(map(int,input().split()))
ans=0
for i in range(N-1):
  if i==0:
    ans+=B[i]
  else:
    val1=B[i-1]
    val2=B[i]
    ans+=min(val1,val2)
ans+=B[-1]
print(ans)

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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	int c0x = x - r, c0y = y - r, c1x = x + r, c1y = y + r;
	bool included = 0 <= c0x && 0 <= c0y && c1x <= w && c1y <= h;
	cout << (included ? "Yes" : "No") << endl;
}



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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];

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

  cout << (v[1]-v[0])+(v[2]-v[1]) << endl;
}

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

int main() {
	string S, P;
	bool check = false;
	cin >> S >> P;
	int X = S.size();
	S = S + S;
	for (int i = 0; i < X; i++) {
		if (S.substr(i, P.size()) == P) check = true;
	}
	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3216
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    boolean[] row = new boolean[N];
    String s = scanner.next();
    for(int i=0;i<N;i++) {
       char n = s.charAt(i);
       if(n == 'E') row[i] = true;
       else row[i] = false;
    }

    int[] countWest = new int[N];
    int count = 0;
    for(int i=0;i<N;i++) {
      countWest[i] = count;
      if(!row[i]) count++;
    }
    int[] countEast = new int[N];
    count = 0;
    for(int i=N-1;i>=0;i--) {
      countEast[i] = count;
      if(row[i]) count++;
    }

    int min = Integer.MAX_VALUE;
    for(int i=0;i<N;i++) {
      int val = countWest[i] + countEast[i];
      if(min > val) min = val;
    }
    System.out.println(min);

    scanner.close();
  }
}


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



int main(){
    long long int k ,x;
    cin>>k>>x;
    if(k*500>=x){
        cout<< "Yes"<< "\n";
    }else{cout<< "No"<< "\n";}
    return 0;
}



Measured memory_bytes: 256
# encoding:utf-8

def main():
	N = int(input())
	cards = list(map(int, input().split()))

	x = cards[0]
	y = sum(cards[1:])
	i = 1
	val = abs(x - y)

	while i < len(cards) - 1:
		x += cards[i]
		y += -cards[i]
		temp = abs(x - y)
		
		if temp == 0:
			val = 0
			break
		if temp < val:
			val = temp

		i += 1

	print(val)

if __name__ == '__main__':
	main()

Measured memory_bytes: 24832
A,B=map(int,input().split())
res=0
for i in range(A,B+1):
    cnt=0
    s=str(i)
    for j in range(len(s)//2):
        if(s[j]==s[len(s)-1-j]):
            cnt+=1
    if(len(s)//2==cnt):
        res+=1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (s == u) {
		cout << a - 1 << ' ' << b << endl;
	}
	else if (t == u) {
		cout << a << ' ' << b - 1 << endl;
	}
	else {
		cout << a << ' ' << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 110

using namespace std;

struct Data{
  int x,y,cost;
  Data(int x=IINF,int y=IINF,int cost=IINF):x(x),y(y),cost(cost){}
};

int H,W,N,ix,iy,ox,oy;
int dx[] = {0,2,0,-2};
int dy[] = {2,0,-2,0};
bool G[MAX][MAX];
bool used[MAX][MAX];

inline bool isValid(int nx,int ny){ return ( 0 <= nx && nx <= 2*W && 0 <= ny && ny <= 2*H ); }

int getValue(){
  if( ix == ox && iy == oy )return 0;
  rep(i,2*H+1)rep(j,2*W+1)used[i][j] = false;
  deque<Data> deq;
  deq.push_back(Data(ix,iy,0));
  used[iy][ix] = true;
  while(!deq.empty()){
    Data data = deq.front(); deq.pop_front();
    int x = data.x, y = data.y;
    rep(i,4){
      int nx = x + dx[i],ny = y + dy[i];
      int mx = (x+nx) / 2, my = (y+ny) / 2;
      if(!isValid(nx,ny) || G[my][mx] || used[ny][nx])continue;
      used[ny][nx] = true;
      if( nx == ox && ny == oy )return data.cost + 1;
      deq.push_back(Data(nx,ny,data.cost+1));
    }
  }
  return IINF;
}

int main(){

  cin >> W >> H >> N;
  rep(i,2*H+1)G[i][0] = G[i][2*W] = true;
  rep(i,2*W+1)G[0][i] = G[2*H][i] = true;
  rep(i,N){
    int sx,sy,dx,dy;
    cin >> sx >> sy >> dx >> dy;
    sx <<= 1, sy <<= 1, dx <<= 1, dy <<= 1;
    REP(y,min(sy,dy),max(sy,dy)+1)REP(x,min(sx,dx),max(sx,dx)+1) G[y][x] = true;
  }

  cin >> ix >> iy >> ox >> oy;
  ix <<= 1, iy <<= 1,ox <<= 1, oy <<= 1;
  ix++,iy++,ox++,oy++;

  int tmp = getValue();
  int ans = 0;
  rep(y,2*H+1)rep(x,2*W+1){
    if( y == 0 || x == 0 || y == 2*H || x == 2*W || G[y][x] )continue;
    if( ( !(y&1) && !(x&1) ) || ( (y&1) && (x&1) ) )continue;
    G[y][x] = true;
    int cost = getValue();
    if(cost != IINF)ans = max(ans,cost-tmp);
    G[y][x] = false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  int N,A[100001],B[100001];
  cin>>N;
  rep(i,N){
    cin>>A[i+1];
    B[A[i+1]]=i+1;
  }
  rep(i,N){
    cout<<B[i+1]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1536
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x = ii()

ans=8
cnt=0
for i in range(4,20,2):
    if(i*100 <= x and x <= (i+2)*100-1):
        print(ans-cnt)
    cnt+=1

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

int main() {
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 0; i < 3; i++) {
    ans *= n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 998244353
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
class segTree{
public:
  const ll Inf = 1e9+10;
  ll n=0;
  vector<ll>node;
  segTree(ll nn){
    n=1;
    while(n<nn)n*=2;
    node.resize(n*2);
    //initializer
    //ex. RMQ
    init(0);
  }
  
  void init(ll hoge){//RMQ
    for(int i=0;i<node.size();i++)node[i]=hoge;
  }

  void init(vector<ll> hoge){//RSQ
    for(int i=0;i<hoge.size();i++)update(i,hoge[i]);
  }

  void update(int index,const ll value){
    index+=n;
    node[index]=value;//RMQ
    while(index > 0){
      index/=2;
      node[index] = ope(node[2*index],node[2*index+1]);
    }
  }
  ll find(int l,int r){
    if(l == r) return node[r+n];
    l += n; r += n;
    ll ans = -Inf;
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans=ope(ans,node[l]); return ans;}
      if(r%2 == 0) ans=ope(ans,node[r]),--r;
      if(l%2) ans=ope(ans,node[l]),++l;
    }
    return ans;
  }
  ll ope(const ll a,const ll b){
    return max(a,b);
  }
};

ll dp[333333]={};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi A(n);
  segTree seg(333333);
  for(auto &a:A)cin>>a;
  for(int i=0;i<n;i++){
    ll ma = 0;
    ma = seg.find(max(0LL,A[i]-k),min(300001LL,A[i]+k));
    dp[i] = ma+1;
  
    seg.update(A[i],dp[i]);
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans = max(ans,dp[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 16132
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;

int64_t f(int64_t n){
    return n*(n-1)/2;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    for(int i=0; i<n; i++){
        cout << ans -f(m[a[i]]) + f(m[a[i]]-1) << endl;
        //printf("%lld\n", ans -f(m[a[i]]) + f(m[a[i]]-1));
    }
    
    return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
const int M = 100005;
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int n,m,ans,a[M],b[M];
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    for(int i=1;i<=m;i++)
    {
        int u=read(),v=read();
        if(a[u]>=a[v]) b[v]=1;
        if(a[u]<=a[v]) b[u]=1;
    }
    for(int i=1;i<=n;i++)
        if(b[i]==0)
            ans++;
    printf("%d\n",ans);
}


Measured memory_bytes: 3956
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  unsigned long long a,b,c;
  rep(i,n+1)
  {
    if(i == 0)
    {
      a = 2;
      c = a;
    }
    else if(i == 1)
    {
      b = 1;
      c = b;
    }
    else
    {
      int buf = c;
      c = a + b;
      a = b;
      b = c;
    }
  }

  cout << c << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    bool ans=true;
    rep(0,i,a)if(!(s[i]>='0'&&s[i]<='9'))ans=false;
    if(s[a]!='-')ans=false;
    rep(0,i,b)if(!(s[a+1+i]>='0'&&s[a+1+i]<='9'))ans=false;
    if(ans)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    ll N, X;
    cin >> N >> X;
    ll ans = N;
    ll a, b;
    a = N - X;
    b = X;
    while (true) {
        if (a % b == 0) {
            break;
        }
        ans += (a / b) * 2 * b;
        ll c = b;
        ll d = a % b;
        a = c;
        b = d;
    }
    ans += ((a / b) * 2 - 1) * b;
    cout << ans << endl;
}


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

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

    int c;
    bool not_yet = true;
    for (int i = 0; i < n; i++) {
        if (not_yet) {
            c = k;
            not_yet = false;
        } else {
            c *= k-1;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string S;
    std::cin >> S;

    int c = 0;
    std::vector<char> B(S.length());

    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (i != S.length()-1 && S[i] != S[i+1]) {
            i++;
            ans++;
            continue;
        }

        if (c == 0 || B[c-1] == S[i]) {
            B[c++] = S[i];
        }
        else {
            c--;
            ans++;
        }
    }

    std::cout << (ans*2) << std::endl;

    return 0;
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
vector < pair < int, int > > ans;
int u[N];
int cur;

int main () {
    cin >> n;
    cur = 1;
    For (i, 1, n) {
        cin >> a[i];
        if (abs(a[cur]) < abs(a[i]) || abs(a[cur] == abs(a[i]) && a[cur] < a[i])) cur = i;
    }
    
    cout << 2 * n << '\n';
    if (a[cur] >= 0) {
        
	    cout << cur << ' ' << 1 << '\n';
        cout << cur << ' ' << 1 << '\n';
		For (i, 2, n) {
			cout << i - 1 << ' ' << i << '\n';
			if (a[i] >= 0)
			    cout << i << ' ' << i << '\n';
			else
			    cout << i - 1 << ' ' << i << '\n';
		}
	} else {
	    cout << cur << ' ' << n << '\n';
	    cout << cur << ' ' << n << '\n';
		FOr (i, n - 1, 1) {
		    cout << i + 1 << ' ' << i << '\n';
		    if (a[i] > 0)
		        cout << i + 1 << ' ' << i << '\n';
		    else
		        cout << i << ' ' << i << '\n';
		}
	}
	return Accepted;
}

// Coded By OB

Measured memory_bytes: 18688
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
if n == 1:
    print("Hello World")
if n == 2:
    a = int(input())
    b = int(input())
    print(a+b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MN=110,MK=1e5+10;
int dp[MK],n,a[MN],k;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=a[0];i<=k;i++)
        for(int j=0;j<n;j++)
            if(i-a[j]>=0 && !dp[i-a[j]])
            {
                dp[i]=1;
                break;
            }
    if(dp[k]) puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int y = sc.nextInt();
    int z = 0;
    boolean flag = false;
    outside: for(int i = 0; i <= n; i++) {
    	for(int j = 0; j <= n - i; j++) {
    		z = n - i - j;
    		if(10000 * i + 5000 * j + 1000 * z == y && y >= 10000 * i + 5000 * j) {
    			flag = true;
    			System.out.println(i + " " + j + " " + z);
    			break outside;
    		}
    	}
    }
    if(flag == false) {
    	System.out.println("-1 -1 -1");
    }
}
}


Measured memory_bytes: 23764
h,w=map(int,input().split())
s=[]*h
b=[[0]*w]*h

for i in range(h):
    b[i]=list(input())
       
for y in range(h):
    for x in range(w):
        if b[y][x]==".":
            b_no=0
            for dy in range(-1,2):
                for dx in range(-1,2):
                    if 0 <= y+dy and y+dy < h and 0 <= x+dx and x+dx <w: 
                        if b[y+dy][x+dx]=="#":
                            b_no += 1
            b[y][x]=b_no
for y in range(h):
    for l in b[y]:
        print(l,end="")
    print()

Measured memory_bytes: 3444
def main():
    n, k = map(int,input().split())
    listS = []
    M = 998244353
    for i in range(k):
        l,r = map(int,input().split())
        # s.append(l)
        # s.append(r)
        listS.append((l,r))
    # listS = list(set(s))
    dp = [0] * n
    dp[0] = 1
    sm = 0
    for i in range(n):
        sm += dp[i] % M
        for lr in listS:
            if lr[0] + i < n:
                dp[i+lr[0]] += sm
            if i + lr[1] + 1 < n :
                dp[i+lr[1]+1] -= sm
            # else:
            #     dp[-1] -= dp[i]

        # print(dp)
    ans = dp[-1]%M
    if ans < 0:ans=0

    print(ans)
    # print(ans%M)
    # print(dp)

if __name__=='__main__':
    main()


Measured memory_bytes: 20028
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    int L[N];
    int max = 0, sum=0;
    for(int i=0;i<N;i++){
        scanf("%d",&L[i]);
        sum += L[i];
        if(L[i]>max){
            max = L[i];
        }
    }
    if(max*2<sum){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))

r = 0
l = sum(arr)
tmp_r = 0
tmp_l = 0
for i in range(n):
    tmp_r = r
    tmp_l = l
    r+=arr[i]
    l-=arr[i]
    if r >= l:
        break
print(min(abs(tmp_r-tmp_l),abs(r-l)))


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

const double PI = acos(-1);

void solve(long long a, long long b, long long x){
  double ret;
  if (a*a*b < x*2) {  // 水が半分より多いとき
    ret = 90.0 - atan2(static_cast<double>(a), static_cast<double>((a*a*b-x)*2)/static_cast<double>(a*a))/PI*180.0;
  } else {  // 水が半分以下のとき
    ret = atan2(static_cast<double>(b), static_cast<double>(x*2)/static_cast<double>(b*a))/PI*180.0;
  }
  std::cout << std::setprecision(12) << ret << std::endl;
}

int main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  long long x;
  scanf("%lld",&x);
  solve(a, b, x);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};

//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};

double arr[10000];
int main()
{
//    READ;
   int n;
   double t,x,a;
   double y;
   cin>>n;
   cin>>t>>a;
   double minn=9999999999999999.0;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
       arr[i]=t-(arr[i]*0.006);
       y=abs(arr[i]-a);
       minn=min(minn,y);

   }
   for(int i=1;i<=n;i++)
   {
       y=abs(arr[i]-a);
       if(y==minn)
       {
           cout<<i<<endl;
           break;
       }

   }
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N, M;
	int s[5], c[5];
	int flag = 1;
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; ++i){
		scanf("%d %d", &s[i], &c[i]);
	}
	
	for(int i = 0; i < M; ++i){
			if(s[i] == 1 && c[i] == 0 && N != 1){
				printf("-1");
				goto F;
			}
		}
		for(int i = 0; i < M - 1; ++i){
			for(int j = i + i; j < M; ++j){
				if(s[i] == s[j] && c[i] != c[j]){
					flag = 0;
					break;
				}
			}
			if(flag == 0){
				break;
			}
		}
		if(flag == 0){
			printf("-1");
			goto F;
		}
		
		for(int i = 0; i < M; ++i){
				for(int j = i + 1; j < M; ++j){
					if(s[i] > s[j]){
						int t = s[i];
						s[i] = s[j];
						s[j] = t;
						t = c[i];
						c[i] = c[j];
						c[j] = t;
					}
				}
			}
	
	if(N == 3){                                 
		if(M == 0)printf("100");
		else if(M == 1){
			if(s[0] == 1) printf("%d00", c[0]);
			else if(s[0] == 2) printf("1%d0", c[0]);
			else printf("10%d", c[0]);
		}
		else{
			int flag_s1_1 = 0;
			for(int i = 0; i < M; ++i){
				if(s[0] == 1){
					if(s[0] == s[M - 1]){
						printf("%d00", c[0]);
						break;
					}
					if(i == 0) printf("%d", c[i]);
					if(i > 0 && s[i] - s[i - 1] == 1) printf("%d", c[i]);
					if(i > 0 && s[i] - s[i - 1] == 2){
						printf("0");
						if(i == M - 1 && s[i] == 3) printf("%d", c[i]); 
					}
					if(i == M - 1 && s[i] != 3) printf("0");
				}
				if(s[0] != 1){
					if(flag_s1_1 == 0){
						printf("1");
						if(s[0] == 3)printf("0");
						flag_s1_1 = 1;
					}
					if(i == 0) printf("%d", c[i]);
					if(i > 0 && s[i] - s[i - 1] == 1) printf("%d", c[i]);
					if(i == M - 1 && s[i] != 3) printf("0");
				}
			}
		}
		
	}
	if(N == 2){
		if(M == 0) printf("10");
		else if(M == 1){
			if(s[0] == 1) printf("%d0", c[0]);
			else if(s[0] == 2) printf("1%d", c[0]);
		}
		else{
			for(int i = 0; i < M; ++i){
				if(s[0] == 1){
					if(s[0] == s[M - 1]){
						printf("%d0", c[0]);
						break;
					}
					if(i == 0) printf("%d", c[i]);
					if(i > 0 && s[i] - s[i - 1] == 1)printf("%d", c[i]);
				}
				if(s[0] != 1){
					printf("1%d", c[M - 1]);
					break;
				}
			}
		}
	}
	if(N == 1){
		if(M == 0) printf("0");
		else if(c[0] == 0){
		    printf("0");
		}else{
			printf("%d", c[0]);
		}
	}
	F:return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    a.append(int(input()))

a.append(0)

dp = [0]*(n+1)
dp[0] = 1
if a[0] == 1:
    dp[1] = 0
    l = 1
else:
    dp[1] = dp[0]
    l = 0
    
for i in range(2,n+1):
    if a[l] != i:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i]%=mod 
    else:
        l += 1

print(dp[-1])

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	if (n % 2 != 0)
	{
		cout << "0" << endl;
	}
	vector<int> diffs;
	for (int i = 0; i < n; ++i)
	{
		int buf;
		cin >> buf;
		diffs.push_back(buf);
	}
	sort(diffs.begin(), diffs.end());
	int left = diffs[n / 2 - 1];
	int right = diffs[n / 2];
	cout << right - left << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	cout<<pow(n,3)<<endl;

	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int x1, x2, y1, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    int dx, dy;
    dx = x2 - x1;
    dy = y2 - y1;
    printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma target("trapv")
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
// #define LOCAL_DEFINE
// #define LOCAL
#define deb(a) cout << #a << " = " << a << '\n'
#define deb2(a, b) cout << #a << " = " << a << ", " << #b << " = " << b << '\n'
#define rep(var,start,end) for(int var=start;var<end;var++)
#define erep(var,start,end) for(int var=start;var<=end;var++)
#define rrep(var,start,end) for(int var=start;var>=end;var--)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define test int t;cin>>t;while(t--)

ll modularExponentiation(ll n, ll p, ll M){
    ll res = 1;
    while(p){
        if(p&1)
            res = (res * n)%M;
        n = (n*n)%M;
        p >>= 1;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int a[n], dp[n];
    
    for(int i = 0; i < n; ++i) cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(dp[i-1] + abs(a[i] - a[i - 1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout << dp[n-1];
}

int main()
{
    bs;
    #ifdef LOCAL
    freopen("Contest/input.txt","r",stdin);
    freopen("Contest/output.txt","w",stdout);
    #endif
    solve();
    // test{
    //    solve(); 
    // }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 4408
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val cityNum = LongArray(N)
        val P = (0 until M).map {
            Triple(it, sc.next().toInt() - 1, sc.next().toInt())
        }.sortedBy { it.third }
        val ans = kotlin.arrayOfNulls<String>(M)
        P.forEach {
            ans[it.first] = "%06d".format(it.second + 1) + "%06d".format(++cityNum[it.second])
        }
        ans.forEach { println(it) }
    }
}


Measured memory_bytes: 137456
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]


n, m, k = map(int, input().split())
friends = [[] for _ in range(n)]
block = [[] for _ in range(n)]
uf = Uf(n)
F = [list(map(int, input().split())) for _ in range(m)]
B = [list(map(int, input().split())) for _ in range(k)]

for e in F:
    friends[e[0] - 1].append(e[1] - 1)
    friends[e[1] - 1].append(e[0] - 1)
    uf.unite(e[0]-1, e[1]-1)

for e in B:
    block[e[0] - 1].append(e[1] - 1)
    block[e[1] - 1].append(e[0] - 1)

ans = [0]*n
for i in range(n):
    ans[i] = uf.size[uf.root(i)] - 1
    for f in friends[i]:
        if uf.same(i, f):
            ans[i] -= 1
    for b in block[i]:
        if uf.same(i, b):
            ans[i] -= 1

print(*ans)


Measured memory_bytes: 133024