akhauriyash/Code-Regression huggingface dataset:
import math
x = int(input())

def isPrime(n):
    check = 1
    nsq = int(math.sqrt(n))
    for i in range(2,nsq+1):
        if n % i != 0:
            check += 1
        else:
            pass
            
    if check == nsq:
        return True
    else:
        False

for i in range(x):
    if isPrime(x+i):
        print(x+i)
        break
    else:
        pass

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[7][2] = {{0,0},{200,380},{300,550},{500,850},{1000,1520},{1200,1870},{1500,2244}};
  int dp[6000][7] = {0};
  for(int i=0; i<6000; i+=100){
    for(int j=1; j<7; j++){
      if(!i){
	for(int k=1;k*frower[j][0]<6000;k++){
	  if(!dp[k*frower[j][0]][j]){dp[k*frower[j][0]][j] = frower[j][1]*k;}
	  else{dp[k*frower[j][0]][j] = min(dp[k*frower[j][0]][j],frower[j][1]*k);}
	}
      }
      else{
	if(dp[i][j-1]){
	  for(int k=0;i+k*frower[j][0]<6000;k++){
	    if(!dp[i+k*frower[j][0]][j]){dp[i+k*frower[j][0]][j] = dp[i][j-1]+frower[j][1]*k;}
	    else{dp[i+k*frower[j][0]][j] = min(dp[i+k*frower[j][0]][j],dp[i][j-1]+frower[j][1]*k);}
	  }
	}
      }
    }
  }
  int n;
  while(cin>>n,n){
    for(int i=n; i<6000; i++){
      if(dp[i][6]){cout <<dp[i][6]<<endl;break;}
    }
  }
  return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> d(n);
	vector<int> sum(n + 2, 0);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
		sum[i + 1] = sum[i] + d[i];
	}
	
	ll ans = 0;
	for(int i = 0; i < n; ++i) {
		int x = sum[n] - sum[i + 1];
		ans += d[i] * x;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Map<Integer, Integer> ansMap = new HashMap<>();
    static int H,W,K;
    static int[][] sums;
    static int[][] s;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        K = sc.nextInt();
        sums = new int[W][H+1];
        s = new int[W][H];
        List<List<Integer>> S = new ArrayList<>();
        for(int i=0;i<W;i++){
            sums[i][0]=0;
        }
        for(int r=0;r<H;r++){
            List<Integer> row = new ArrayList<>();
            String sline = sc.next();
            for(int c=0;c<W;c++){
                int val = sline.charAt(c)-'0';
                s[c][r] = val;
                row.add(val);
                sums[c][r+1] = sums[c][r] + val;
            }
            S.add(row);
        }
        int minCut = 1_000_000_000;
        for(int code=0;code<Math.pow(2,H-1);code++){
            //System.out.println(code +":"+getAns(code) + "-" + bitcnt(code));
            minCut = Math.min(minCut, getAns(code)+bitcnt(code));
        }
        System.out.println(minCut);
    }

    private static int bitcnt(int a){
        int sum=0;
        while(a > 0){
            if((a & 0x01) >0){
                sum++;
            }
            a = (a >> 1);
        }
        return sum;
    }

    private static int getAns(int code){
        int[] groups = new int[H];
        groups[0]=0;
        for(int i=0;i<H-1;i++){
            groups[i+1] = groups[i] + ((code >> i) & 0x01);
        }
        int groupCnt = groups[H-1]+1;
        int[] nowSum = new int[groupCnt];
        int[] nxtSum = new int[groupCnt];
        Arrays.fill(nowSum, 0);
        Arrays.fill(nxtSum, 0);
        int split=0;
        for(int w=0;w<W;w++){
            boolean cutFlag = false;
            for(int g=0;g<groupCnt;g++){
                nxtSum[g] = nowSum[g];
            }
            for(int h=0;h<H;h++){
                nxtSum[groups[h]] += s[w][h];
                if(nxtSum[groups[h]] > K){
                    cutFlag = true;
                }
            }
            if(cutFlag){
                split++;
                for(int i=0;i<groupCnt;i++) {
                    nowSum[i] = nxtSum[i]-nowSum[i];
                    if(nowSum[i] > K){
                        return 1_000_000_000;
                    }
                }
            }else{
                for(int i=0;i<groupCnt;i++) {
                    nowSum[i] = nxtSum[i];
                }
            }
        }
        return split;
    }
    private static void printInts(int[] a){
        for(int p:a){
            System.out.print(p);
        }
        System.out.println();
    }
}


Measured memory_bytes: 23412
A,B,C = map(int,input().split())

amaris = []

flag = False
count = 1
tmp = A
while True:
    amari = tmp % B
    if C == amari:
        flag = True
        break
    if amari in amaris:
        break
    amaris.append(amari)
    count += 1
    tmp = A * count

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll r;
  cin >> r;

  double ans = 2 * M_PI * r;

  cout << setprecision(12) << ans << ln;

  return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <tuple>
#include <map>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for(int i = 0; i < N; ++i){
    cin >> x[i] >> y[i];
  }
  map<tuple<int, int>, int> r;
  for(int i = 0; i < N; ++i){
    for(int j = i + 1; j < N; ++j){
      int dx = x[i] - x[j], dy = y[i] - y[j];
      auto add = [&](int dx, int dy){
        auto const key = make_tuple(dx, dy);
        auto const it = r.find(key);
        if(it != r.end()){
          it->second += 1;
        }else{
          r.emplace(key, 1);
        }
      };
      add(dx, dy); add(-dx, -dy);
    }
  }
  int m = 0;
  for(auto it = r.cbegin(); it != r.cend(); ++it){
    if(m < it->second){
      m = it->second;
    }
  }
  cout << N - m << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] params = sc.next().split("");

        int nums1 =Integer.parseInt(params[0]);
        int nums2 =Integer.parseInt(params[1]);
        int nums3 =Integer.parseInt(params[2]);

        int sum = nums1 + nums2 + nums3;
         System.out.println(sum);
    }
}

Measured memory_bytes: 21716
mod scanner {
    use std::io::StdinLock;
    use std::str::FromStr;
    use std::io::BufRead;
    pub struct Scanner<'a> {
        stdin: StdinLock<'a>,
        buf: String,
        token: Vec<String>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(stdin: StdinLock) -> Scanner {
            Scanner {
                stdin: stdin,
                buf: String::new(),
                token: vec![],
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            loop {
                if let Some(token) = self.token.pop() {
                    return token.parse().ok().unwrap();
                }
                self.buf.clear();
                self.stdin.read_line(&mut self.buf).unwrap();
                self.token = self.buf.trim().split_whitespace().rev().map(String::from).collect();
            }
        }
    }
}

fn main() {
    run();
}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut x = vec![false; n + 1];
    let mut y = vec![false; n + 1];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        if a == 1 {
            x[b] = true;
        }
        if b == n {
            y[a] = true;
        }
    }
    if x.iter().zip(y.iter()).any(|(a, b)| *a && *b) {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4476
N,*a = map(int, open(0).read().split())
b = [x for x in a if x % 4 == 0]
c = [x for x in a if x % 2 == 0]
d = [x for x in a if x % 2 == 1]
if len(b) >= len(a) // 2:
    print('Yes')
elif len(d) <= len(b):
    print('Yes')
elif len(c) == len(a):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
 ll N;
  cin>>N;
  
  for(ll i=1;i<=9;i++){
    if(N%i==0){
if(N/i<=9){
  cout<<"Yes"<<endl;
  break;
  
}
}
    else{
      if(i==9){
        cout<<"No"<<endl;
      }

  }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_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; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> parent;

  // 作るときは parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(const int& n = 0) : parent(n, -1) {}

  // x がどのグループに属しているか調べる
  int find(const int& x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  // x と y をくっつける  O(log n)
  bool unite(int x, int y) {
    // x と y を直接くっつけるのではなく，root(x) に root(y) をくっつける
    x = find(x);
    y = find(y);
    if (x == y) return false;  // すでにくっついているからくっつけない

    // 大きい方(x) に小さい方(y)をくっつけたい 大小が逆だったらひっくり返す
    if (size(x) < size(y)) swap(x, y);

    parent[x] += parent[y];  // x のサイズを更新する
    parent[y] = x;  // y の親を x に変更する
    return true;
  }

  // 自分のいるグループの頂点数を調べる
  int size(const int& x) { return -parent[find(x)]; }

  // x と y が同じグループに属しているか否か
  bool same(const int& x, const int& y) { return find(x) == find(y); }
};

// cut 番目の bridge が無かったときに全体で1つにつながるか？
bool judge(int n, vector<pair<int, int>> bridges, int cut) {
  UnionFind uf(n);
  for (int i = 0; i < bridges.size(); i++) {
    if (i == cut) continue;
    uf.unite(bridges[i].first, bridges[i].second);
  }
  return n != uf.size(0);
}

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> bridges;
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    bridges.emplace_back(a, b);
  }

  int ans = 0;
  rep(i, m) {
    if (judge(n, bridges, i)) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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

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

  if (a <= 9 && b <= 9) cout << a*b << endl;
  else cout << -1 << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	for (int& i : h) cin >> i;
	int dp[100000][2];
	dp[0][0] = dp[0][1] = 0;
	dp[1][0] = dp[1][1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; ++i) {
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + abs(h[i] - h[i - 1]);
		dp[i][1] = min(dp[i - 2][0], dp[i - 2][1]) + abs(h[i] - h[i - 2]);
	}
	cout << min(dp[N - 1][0], dp[N - 1][1]);
}

Measured memory_bytes: 1408
N = int(input())
S = input().strip()
#print(S)
for b, c in ["SS", "SW", "WS", "WW"]:
#for b, c in ["SW"]:
    fb, fc = b, c
    rs = [""]*N
    for i in range(N):
        cc = c
        if S[i] == 'o':
            if c == "S":
                c = "S" if b == "S" else "W"
            else:
                c = "W" if b == "S" else "S"
        else:
            if c == "S":
                c = "W" if b == "S" else "S"
            else:
                c = "S" if b == "S" else "W"
        b = cc
        if i != N-1:
            rs[i+1] = c
        else:
            rs[0] = c
    if rs[0] == fc and rs[-1] == fb:
        print("".join(rs))
        break
else:
    print(-1)


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

int main() {
  int n; cin >> n;
  vector<int> A(n-1,0);
  vector<int> m(n,0);
  rep(i,n-1) {
    int a; cin >> a;
    A[i] = --a;
    m[A[i]] += 1;
  }
  rep(i,n) cout << m[i] << endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}
}


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

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> ac(n);
  vector<int> wa(n);
  
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    if (s == "AC")
      ac.at(p-1) = 1;
    if(s == "WA" && ac.at(p-1) == 0)
      wa.at(p-1)++;
  }
  
  int AC = 0;
  int WA = 0;
  rep(i,n) {
    AC += ac.at(i);
    if (ac.at(i) == 1) WA += wa.at(i);
  }
  cout << AC << " " << WA <<endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
int main(void){
    // Your code here!
    

int h, w, i, j; 
while(1){ 
    scanf("%d", &h); 
    scanf("%d", &w); 
    if (h==0&&w==0) { 
        break; } 
        else { 
            for (j=0;j<h;j++){ 
            for (i=0;i<w;i++){ 
                if ((i+j)%2==1) { 
                    printf("."); } 
                    else { printf("#"); } } 
                    printf("\n"); } 
                    printf("\n"); } } 
                    return 0; } 



  

 



 


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

int main() {
  
  int N;
  string S;
  
  cin >> N;
  cin >> S;
  
  int num = N;
  
  for(int i = 0;i < N - 1;++i){
    if(S[i] == S[i + 1]){
      num = num - 1;
    }
  }
  
  cout << num << endl;
}




Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

	string N;

	cin >> N;

	if(N[0] == '9' || N[1] == '9'){
		cout << "Yes";
	}else{
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pub push_back
#define x first
#define all(a) a.begin(), a.end()
#define y second
#define mp make_pair
#define ll long long
#define db double   
using namespace std;

int a[100007];

int main() {
    srand(time(NULL) + 'D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N');
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);  
    //freopen("expr.in", "r", stdin);
    //freopen("expr.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) a[i]--;
    int ans = 0;
	for (int i = 1; i < n; i++){
		int w1 = 0, w2 = 0;
		if (a[i - 1] == i - 1) w1 = 1;
		if (a[i] == i) w2 = 1;
		if (w1 == 1 && w2 == 1){
			swap(a[i], a[i - 1]);
			ans++;
		} else if (w1 == 1 && w2 == 0){
			swap(a[i], a[i - 1]);
			ans++;
		} else if (w1 == 0 && w2 == 1){
			if (i == n - 1){
				swap(a[i], a[i - 1]);
				ans++;
			}
		} else {

		}
	}
	cout << ans;
}

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

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

using namespace std;

const int INF=1<<29;

template<class T>
class segment_tree{
	int n;
	vector<T> dat;

	T query(int l,int r,int a,int b,int u){
		if(l<=a && b<=r) return dat[u];

		T res=INF;
		int c=(a+b)/2;
		if(l<c && a<r) res=min(res,query(l,r,a,c,2*u+1));
		if(l<b && c<r) res=min(res,query(l,r,c,b,2*u+2));
		return res;
	}

public:
	segment_tree(int N){
		for(n=1;n<N;n*=2);
		dat.assign(2*n-1,INF);
	}

	void update(int u,T v){
		u+=n-1;
		dat[u]=min(dat[u],v);
		while(u>0) u=(u-1)/2, dat[u]=min(dat[2*u+1],dat[2*u+2]);
	}

	T query(int l,int r){ return query(l,r,0,n,0); }
};

int main(){
	int n,m;
	string s; cin>>n>>m>>s;

	segment_tree<int> dp(n+1);
	dp.update(n,0);
	for(int i=n-1;i>=0;i--) if(s[i]=='0') {
		dp.update(i,dp.query(i+1,min(i+m,n)+1)+1);
	}

	if(dp.query(0,1)==INF){ puts("-1"); return 0; }

	int c=dp.query(0,1),i=0;
	while(i<n){
		int lo=i,hi=min(i+m,n);
		while(hi-lo>1){
			int mi=(lo+hi)/2;
			if(dp.query(i,mi+1)==c-1) hi=mi;
			else                      lo=mi;
		}
		printf("%d ",hi-i);
		i=hi;
		c--;
	}

	return 0;
}


Measured memory_bytes: 1664
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  edge <- (\[x, y] -> zip x y) . transpose <$> getInt2DListBC
  let graph = foldl makeGraph M.empty edge
      neighbor = fromJust $ M.lookup 1 graph
      neighbors = sort . concat $ map (\x -> fromJust $ M.lookup x graph) neighbor
  if n == last neighbors then putStrLn "POSSIBLE"
                         else putStrLn "IMPOSSIBLE"

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

type Graph = M.IntMap [Int]

makeGraph :: Graph -> (Int, Int) -> Graph
makeGraph graph (x, y) =
  let nX = M.lookup x graph
      nY = M.lookup y graph
      vX = if nX == Nothing
             then M.insert x [y] graph
             else M.insert x ((:) y $ fromJust nX) graph
  in if nY == Nothing
        then M.insert y [y] vX
        else M.insert y ((:) x $ fromJust nY) vX


Measured memory_bytes: 94588
import numpy as np

N = int(input())
lisA = list(map(int,input().split()))
arrA = np.array(lisA)

cumsumA = np.cumsum(arrA)

ans = 10**9 * 2 * 10**5
for num in cumsumA[:-1]:
    ans = min(ans,abs(num*2 - cumsumA[-1]))

print(ans)


Measured memory_bytes: 33032
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

R = read_a_int()
print(R * 2 * 3.14159265359)


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  vector<ll> d(N);
  rep0(i, N) cin >> d[i];
  ll ans = 0;
  rep0(i, N) {
    rep(j, i + 1, N) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[""]*n
for i in range(n):
    s[i]=input()
ss=list(set(s[0]))
ss.sort()

stmin=[50]*len(ss)
for si in s:
    for ii in range(len(ss)):
        stmin[ii]=min(stmin[ii],si.count(ss[ii]))

t=""
for i in range(len(ss)):
    t=t+ss[i]*stmin[i]
print(t)


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N; cin >> N;
  int num = N, node = 0;
  while (num > 0){
    node++; num /= 2;
  }

  vector <int> cnt(node); num = N;
  for (int i = node - 1; i >= 0; i--){
    cnt[i] = num % 2; num /= 2;
  }
  

  vector <int> A, B, C;
  for (int i = 1; i <= node - 1; i++){
    A.push_back(i); A.push_back(i);
    B.push_back(i + 1); B.push_back(i + 1);
    C.push_back(pow(2, node - 1 - i));
    C.push_back(0);
  }

  int m = pow(2, node - 1);
  for (int i = 1; i < node; i++){
    if (cnt[i] == 1){
      A.push_back(1);
      B.push_back(i + 1);
      C.push_back(m);
      m += pow(2, node - i - 1);
    }
  }
  cout << node << " " << A.size() << endl;
  
  for (int i = 0; i < A.size(); i++){
    cout << A[i] << " " << B[i] << " " << C[i] << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N, M, Q;
vector<int> a, b, c, d;
vector<int> xs;

int dfs(int idx) {
    if (idx > N) {
        int sum = 0;
        rep(i, 0, Q) {
            if (xs[b[i]] - xs[a[i]] == c[i]) sum += d[i];
        }
        return sum;
    }

    int ret = 0;
    repc(v, xs[idx - 1], M) {
        xs[idx] = v;
        chmax(ret, dfs(idx + 1));
    }

    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    read(N, M, Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, 0, Q) { read(a[i], b[i], c[i], d[i]); }

    xs.resize(N + 1);
    xs[0] = 1;

    print(dfs(1));

    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
	int n;
	string s;
	cin>>n>>s;
	
	vector<int> rightI(s.size(),0);
	vector<int> rightOI(s.size(),0);
	vector<int> leftJ(s.size(),0);
	vector<int> leftJO(s.size(),0);

	rep(i,s.size())if(s[i]=='I')rightI[i]++;
	for(int i=s.size()-2;i>=0;i--){
		rightI[i]+=rightI[i+1];
	}
	
	rep(i,s.size())if(s[i]=='O')rightOI[i]=rightI[i];
	for(int i=s.size()-2;i>=0;i--){
		rightOI[i]+=rightOI[i+1];
	}
	
	rep(i,s.size())if(s[i]=='J')leftJ[i]++;
	rep(i,s.size()-1){
		leftJ[i+1]+=leftJ[i];
	}
	
	rep(i,s.size())if(s[i]=='O')leftJO[i]=leftJ[i];
	rep(i,s.size()-1){
		leftJO[i+1]+=leftJO[i];
	}
	
	int sum = 0;
	
	rep(i,rightOI.size()){
		if(s[i]=='J')sum+=rightOI[i];
	}
	
	int J = sum+rightOI[0];
	int I = sum+leftJO[leftJO.size()-1];
	int O = 0;
	rep(i,s.size()+1){
		int l=0,r=0;
		if(i!=0)l = leftJ[i-1];
		if(i!=s.size())r = rightI[i];
		O = max(O,l*r);
	}
	O+=sum;
	
	cout<<max(J,max(O,I))<<endl;
}

Measured memory_bytes: 6296
#include<bits/stdc++.h>
using namespace std;
long long st[3]={127,131,137};
long long mod[3]={123457,(long long)(1e7+7),(long long)(1e7+9)};
vector<long long>de[3];
void init(int n)
{
	int i,j;
	for(i=0;i<3;i++)
	{
		de[i].resize(n+1);
		de[i][0]=1;
		for(j=1;j<n+1;j++)
			de[i][j]=(de[i][j-1]*st[i])%mod[i];
	}
}
struct hash3
{
	long long h[3];
	int sz;
	hash3()
	{
		h[0]=h[1]=h[2]=0;
		sz=0;
	}
	hash3(string s)
	{
		h[0]=h[1]=h[2]=0;
		sz=0;
		for(int i=0;i<sz;i++)
			(*this)+=hash3(s[i]);
	}
	hash3(char c)
	{
		h[0]=h[1]=h[2]=c;
		sz=1;
	}
	hash3 operator=(hash3 const &x)
	{
		for(int i=0;i<3;i++)
			h[i]=x.h[i];
		sz=x.sz;
		return *this;
	}
	hash3 operator+(hash3 x)
	{
		hash3 ans;
		for(int i=0;i<3;i++)
			ans.h[i]=(h[i]*de[i][x.sz]+x.h[i])%mod[i];
		ans.sz=sz+x.sz;
		return ans;
	}
	hash3 operator+=(hash3 x)
	{
		(*this)=(*this)+x;
		return *this;
	}
	hash3 operator-(const hash3 &x)
	{
		hash3 ans;
		for(int i=0;i<3;i++)
		{
			ans.h[i]=h[i]-(de[i][sz-x.sz]*x.h[i])%mod[i];
			if(ans.h[i]<0)ans.h[i]+=mod[i];
		}
		ans.sz=sz-x.sz;
		return ans;
	}
	hash3 operator-=(hash3 x)
	{
		(*this)=(*this)-x;
		return *this;
	}
	bool operator==(hash3 const &a)
	{
		int i;
		for(i=0;i<3;i++)
			if(this->h[i]!=a.h[i])return 0;
		return 1;
	}
};
vector<hash3>m[123457];
bool fi(hash3 x)
{
	int i;
	for(i=0;i<(int)m[x.h[0]].size();i++)
		if(m[x.h[0]][i]==x)return 1;
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j;
	string s;
	cin>>n>>s;
	init(n+1);
	vector<hash3>v(n+1);
	for(i=0;i<n;i++)
		v[i+1]=v[i]+hash3(s[i]);
	for(i=1;i<n;i++)
	{
		for(j=i;j+i-1<=n;j++)
		{
			if(fi(v[j+i-1]-v[j-1]))break;
			hash3 x=v[j]-v[j-i];
			m[x.h[0]].push_back(x);
		}
		if(j+i-1>n)break;
	}
	cout<<i-1<<'\n';
}


Measured memory_bytes: 207488
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void)

{

char num_str[1002];

int num;

long sum = 0;

int i;

  int stdim = 0; char tmp;

while (1)

{

fgets(num_str,sizeof(num_str),stdin);

if (num_str[0] == '0') break;

for (i = 0; i < strlen(num_str)-1; i++)

{

tmp = num_str[i];

num   = atoi(&tmp);

sum = sum + num;

}

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

sum = 0;

memset(num_str, 1001,0);

}

return 0;

}
 

Measured memory_bytes: 528
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<ll> f(n + 1), g(n + 1);
    f[1] = 0, g[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if (i % 2 == 0) {
            f[i] = f[i - 2] + a[i - 2];
            g[i] = max(f[i - 2], g[i - 2]) + a[i - 1];
        } else {
            f[i] = max(f[i - 1], g[i - 1]);
            g[i] = max(f[i - 2], g[i - 2]) + a[i - 1];
        }
    }
    cout << max(f[n], g[n]);
}

Measured memory_bytes: 7948
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define pii pair<int,int>
#define S second
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
#define mod 1000000007
#define pb push_back
const long long INF = 1000000000000000000LL;
//const int WASTE=∞
const int N=1e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  	// cout<<fixed;
  	// cout.precision(10);
   	int n;
   	cin>>n;
   	int a[n];
   	for(int x=0;x<n;x++) cin>>a[x];
   	int dp[n];
   	dp[0]=0; dp[1]=abs(a[1]-a[0]);
   	for(int x=2;x<n;x++){
   		dp[x]=min(dp[x-1]+abs(a[x]-a[x-1]),dp[x-2]+abs(a[x-2]-a[x]));
   	}
   	cout<<dp[n-1];
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
  	return 0;
}



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

int main()
{
    int n,m;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    cin>>m;
    vector<int>b(m);
    REP(i,m)cin>>b[i];
    vector<int>c;
    set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
    for(auto i:c)cout<<i<<endl;
}



Measured memory_bytes: 4636
#include <bits/stdc++.h>
using namespace std;
long A,B;
main()
{
    cin>>A>>B;
    long ans=0;
    while(A%4&&A<B)ans^=A++;
    while(B%4!=3&&A<B)ans^=B--;
    if(0<=B-A&&B-A<4)ans^=A++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n, m, p[1001];

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    for(int i = 0; i < n; i++){
      cin >> p[i];
    }
    sort(p, p+n);

    int s=0;
    for(int i = n-1, j=1; i >= 0; i--, j++){
      if(j == m){
	j = 0;
      } else {
	s += p[i];
      }
    }
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

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

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }
    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

template <typename T>
string tostr(const T& input) {
    ostringstream oss;
    oss << input;
    return oss.str();
}

int main()
{

 int N,K;
 cin>>N>>K;

 vector<int> l(N);

 rep(i,N) cin>>l[i];

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

 int s=0;

 for(int i=N-1;i>N-K-1;--i){
 s+=l[i];
 }

cout<<s<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

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

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
#define int long long int

const lli MOD = 1000000007LL;
inline lli mod_mul(lli x, lli y) {
    return (x * y) % MOD;
}
inline lli mod_add(lli x, lli y) {
    return (x + y) % MOD;
}

signed main() {
    string S; cin >> S;
    int len = S.length();
    reverse(S.begin(), S.end());

    // int dp[100001][13];
    vector< vector<int>> dp(len + 1, vector<int>(13, 0));
    dp[0][0] = 1;

    int digit = 1;
    for (int i = 1; i <= len; i++) {
        char c = S[i - 1];
        if (c != '?') {
            int p = c - '0';
            int r = (p * digit) % 13;
            for (int j = 0; j < 13; j++) {
                dp[i][j] = dp[i - 1][(13 + j - r) % 13];
            }
        } else {
            for (int p = 0; p < 10; p++) {
                int r = (p * digit) % 13;
                for (int j = 0; j < 13; j++) {
                    dp[i][j] = mod_add(dp[i][j], dp[i - 1][(13 + j - r) % 13]);
                }
            }
        }
        digit = (digit * 10) % 13;
    }
    cout << dp[len][5] << endl;
    return 0;
}


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

using namespace std;

int data[500009], rr[500009], n;

void sift_up(int p)
{
    //cout << "SIFT_UP" << p << endl;
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
    bool done = false;
    if(p == 1)return;
    while(p != 1 && ! done)
    {
        if(data[p] > data[p >> 1])
            swap(data[p], data[p >> 1]);
        else done = true;
        p >>= 1;
    }
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
}

void sift_down(int p)
{
    //cout << "SIFT_DOWN" << endl;
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
    bool done = false;
    if((p << 1) > n)return;
    while((p << 1) <= n && !done)
    {
        p <<= 1;
        if(p + 1 <= n && data[p] < data[p + 1])p ++;
        if(data[p >> 1] < data[p])
            swap(data[p], data[p >> 1]);
        else done = true;
    }
    //cout << n << endl;
    //for(int i = 1; i <= n; i ++)
    //    cout << data[i] << ' ';
    //cout << endl;
}

void insert_node(int x)
{
    n ++;
    data[n] = x;
    sift_up(n);
}

void delete_node(int p)
{
    int x = data[p], y = data[n];
    //cout << x << ' ' << y << endl;
    n --;
    if(p == n + 1)return ;
    data[p] = y;
    if(y >= x)sift_up(p);
    else sift_down(p);
}

long long delete_max(int p)
{
    long long x = data[1];
    delete_node(1);
    return x;
}

void makeheap()
{
    for(int i = n >> 1; i >= 1; i --)
        sift_down(i);
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)
        scanf("%d", &data[i]);
    makeheap();
    for(int i = 1; i <= n; i ++)
        printf(" %d", data[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 5060
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var input = ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var Y= int.Parse(input[1]);

        var answer = new int[3] { -1, -1, -1 };
        for(int x = N; x > -1; x--)
        {
            for(int y = N-x; y > -1; y--)
            {
                for(int z = N-x-y; z > -1; z--)
                {
                    if((10000 * x + 5000 * y + 1000 * z) == Y
                     && x+y+z == N)
                    {
                        answer[0] = x;
                        answer[1] = y;
                        answer[2] = z;
                        goto END;
                    }
                }
            }
        }
        
        END:
        WriteLine(string.Join(" ", answer));
    }
}


Measured memory_bytes: 13268
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] = '#'

if a[0][0] == "#" and a[0][1] == "#" and a[0][2] == '#':
    print('Yes')
elif a[1][0] == "#" and a[1][1] == "#" and a[1][2] == '#':
    print('Yes')
elif a[2][0] == "#" and a[2][1] == "#" and a[2][2] == '#':
    print('Yes')
elif a[0][0] == "#" and a[1][0] == "#" and a[2][0] == '#':
    print('Yes')
elif a[0][1] == "#" and a[1][1] == "#" and a[2][1] == '#':
    print('Yes')
elif a[0][2] == "#" and a[1][2] == "#" and a[2][2] == '#':
    print('Yes')
elif a[0][0] == "#" and a[1][1] == "#" and a[2][2] == '#':
    print('Yes')
elif a[0][2] == "#" and a[1][1] == "#" and a[2][0] == '#':
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
ans = 0
minus = 0
q = abs(a[0])
for i in a:
    ans += abs(i)
    q = min(q,abs(i))
    if i < 0:
        minus += 1

if minus%2 == 0:
    print(ans)
else:
    print(ans - 2*q)

Measured memory_bytes: 64880
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	int q;
	scanf("%d", &q);
	vector<int> t(q);
	rep(i, q)scanf("%d", &t[i]);
	sort(all(a));
	int ans = 0;
	rep(i, q) {
		ans += binary_search(all(a), t[i]);
	}
	printf("%d\n", ans);

	Please AC;
}



Measured memory_bytes: 3268
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


# すべての通り(2^n-1)からnCa,nCbを引けば良い
MOD = 10**9 + 7
n, a, b = read_ints()
tmp = pow(2, n, MOD) - 1
ans = tmp - combination_mod(n, a, MOD) - combination_mod(n, b, MOD)
print(ans % MOD)


Measured memory_bytes: 38640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    int N;
    cin >> N;
    vector<string> a(N);
    int ok = 0;
    rep(i, N) {
        cin >> a[i];
        rep(j, N)ok |= a[i][j] == '#';
    }
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }

    int whiteColumns = 0;
    rep(j, N) {
        int found = 0;
        rep(i, N)found |= a[i][j] == '.';
        whiteColumns += found;
    }

    int ans = INT_MAX;
    rep(i, N) {
        int white = 0;
        rep(j, N)if(a[i][j] == '.')white++;
        int plus = 1;
        rep(j, N)if(a[j][i] == '#') {
            plus = 0;
        }
        int need = white + plus;
        smin(ans, need + whiteColumns);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int lenth[3];
    scanf("%d%d%d", &lenth[0], &lenth[1], &lenth[2]);

    if (lenth[1] - lenth[0] == lenth[2] - lenth[1]) printf ("YES");
    else printf ("NO");

    return (0);
}


Measured memory_bytes: 128
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=0;
    long long  n;
    cin >> n;
    for(int i=1; i<10; i++)
    {
       for(int j=1; j<10; j++)
        {
            if (i*j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}




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

int main(){
    int N,D;
    cin>>N>>D;
    vector<vector<int>> v(N, vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>v[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            for(int k=0;k<D;k++){
                sum+=pow(v[i][k]-v[j][k],2);
            }
            int sq=sqrt(sum);
            if(sum==sq*sq)ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

int main(){
 ll H,W; cin>>H>>W;
 ll ans = 0;
 if(W % 2 != 0){

    for(int i=0;i<H;i++){
   ll n = (W + 1)/2;
   ll m = n-1;

   if(i%2 == 0){
     ans += n;
   } else {
     ans += m;
   }

 }

 } else {
   ans = H * W / 2;
 }

 if(H == 1 or W == 1) ans = 1;


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

Measured memory_bytes: 256