akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer;

public class Main {
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
        long [] readarray(int sz){
            long [] ret = new long[sz];
            for(int i = 0; i<sz; i++)ret[i] = nextLong();
            return ret;
        }
    } 
    public static void main(String[] args){
        IO fs = new IO();
        int n = fs.nextInt();
        long [] a = fs.readarray(n);
        long ans = Long.MAX_VALUE;
        for(long i = -1000000; i<=1000000; i++){
            long curr = 0;
            for(int j = 0; j<n; j++){
                curr += ((a[j]-i)*(a[j]-i));
            }
            ans = Math.min(ans,curr);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25872
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int count = 0;
		int flag = 0;
		ArrayList<Integer> array = new ArrayList<Integer>(10000);
		for (int i = 0; i < gate * 2; i++) {
			array.add(sc.nextInt());
		}
		int max=0;
			for(int i=0;i<gate*2;i+=2) {
				if(array.get(i)>=max) max=array.get(i);
			}

		int min=array.get(1);
			for(int i=1;i<gate*2;i+=2) {
				if(array.get(i)<=min) min=array.get(i);
			}

			for(int i=1;i<=card;i++) {
				if(i>=max&&i<=min) {
					count++;
				}
			}


		System.out.println(count);

	}
}



Measured memory_bytes: 67800
#include <iostream>
#include <iomanip>
#include <stdio.h>


using namespace std;


int main() {
    cout << fixed << setprecision(3);
     double a,b, c, d, e, f, x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        y=(a*f-c*d)/(a*e-d*b);
        x=(c-b*y)/a;

        cout << x << " " << y << "\n";
    }

	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

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

int main(){
	
	ll n,m;cin >> n >> m;
	string s;cin >> s;
	string t;cin >> t;
	
	for(ll i = n;i <= n*m;i += n){
		ll now = i;
		//cout << now << endl;
		if(now % m != 0)continue;
		//cout << (now / n) <<  " " << (now / m) << endl;
		ll A = now / n;
		ll B = now / m;
		ll tmp = gcd(A,B);
		A /= tmp;
		B /= tmp;
		ll placeA = 0;
		ll placeB = 0;
		bool flag = true;
		while(placeA < n && placeB < m){
			//cout << "   " << placeA << " " << placeB << endl;
			if(s[placeA] != t[placeB]){
				flag = false;
				break;
			}
			placeA += B;
			placeB += A;
		}
		if(flag){
			cout << now << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	
	return 0;
}

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

int main(){
 int N;cin >> N;
 string S = "";
 
 while(N){
  if(N % 2){
	 N--;
	 S = '1' + S;
	}
	else{
	 S = '0' + S;
	}
	N /= -2;
 }
 if(S == "")
  S = '0';

 cout << S << endl;
 return 0;
}



Measured memory_bytes: 256
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Energy Drink Collector
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	sc.Split(bufio.ScanWords)
	A := make(map[int]int, N)
	B := make([]int, 0)
	var a, b int
	for i := 0; i < N; i++ {
		a = nextInt()
		b = nextInt()
		if A[a] == 0 {
			B = append(B, a)
		}
		A[a] += b
	}

	var count int
	var cost int
	sort.Sort(sort.IntSlice(B))

	for i := 0; i < N; i++ {

		if M >= count+A[B[i]] {
			count += A[B[i]]
			cost += A[B[i]] * B[i]
		} else {
			cost += (M - count) * B[i]
			count = M
		}

		if count == M {
			break
		}
	}

	fmt.Println(cost)
}


Measured memory_bytes: 8672
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}
#define INF 1e9

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int h, w; cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  ch--, cw--, dh--, dw--;
  vector<vector<char>> field(h, vector<char>(w));
  vector<vector<int>> field_c(h, vector<int>(w, INF));
  for(int i = 0; i < h; i++){
    string s; cin >> s;
    for(int j = 0; j < w; j++){
      field[i][j] = s[j];
    }
  }
  field_c[ch][cw] = 0;
  auto comp = [](pair<int, pii>& a, pair<int, pii>& b){
  return a.first > b.first; //昇順
};
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, decltype(comp)> q(comp);
  q.push({0, {ch, cw}});
  while(!q.empty()){
    auto now = q.top(); q.pop();
    int y = now.second.first;
    int x = now.second.second;
    int c = now.first;
    for(int i = 0; i < 4; i++){
      if(!is_in_field(y+f_dir[0][i], x+f_dir[1][i], h, w) || field[y+f_dir[0][i]][x+f_dir[1][i]] == '#') continue;
      if(field_c[y+f_dir[0][i]][x+f_dir[1][i]] > c){
        field_c[y+f_dir[0][i]][x+f_dir[1][i]] = c;
        q.push({c, {y+f_dir[0][i], x+f_dir[1][i]}});
      }
    }
    for(int i = -2; i <= 2; i++){
      for(int j = -2; j <= 2; j++){
        if(i == 0 && j == 0) continue;
        if(!is_in_field(y+i, x+j, h, w) || field[y+i][x+j] == '#') continue;
        if(field_c[y+i][x+j] > c+1){
          field_c[y+i][x+j] = c+1;
          q.push({c+1, {y+i, x+j}});
        }
      }
    }
  }

  if(field_c[dh][dw] == INF) cout << -1 << endl;
  else cout << field_c[dh][dw] << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 8612
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 2999 + 10;

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

    int n, k;
    cin >> n >> k;
    vector<int> ar(n);
    for (auto &i : ar) cin >> i;
    vector<int> dp(k+1, 0);

    for (int stones = 0; stones <= k; ++stones) {
        for (int i = 0; i < n; ++i) {
            if (stones - ar[i] >= 0) {
                if (!dp[stones - ar[i]]) {
                    dp[stones] = 1;
                }
            }
        }
    }

    cout <<  (dp[k] ? "First" : "Second") << endl; 


    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    int n;
    scanf("%d", &n);

    if(n == 0) break;

    int mass[100][100] = {};
    int hand[100][100] = {};
    REP(i,n){
      REP(j,n){
        scanf("%d", &mass[i][j]);
      }
    }

    REP(i,n){
      int min_h = INF;
      REP(j,n){
        min_h = min(min_h, mass[i][j]);
      }
      REP(j,n){
        if(mass[i][j] == min_h){
          hand[i][j]++;
        }
      }
    }

    REP(i,n){
      int max_h = -1;
      REP(j,n){
        max_h = max(max_h, mass[j][i]);
      }
      REP(j,n){
        if(mass[j][i] == max_h){
          hand[j][i]++;
        }
      }
    }

    int ans = 0;
    REP(i,n){
      REP(j,n){
        if(hand[i][j] == 2) ans = max(ans, mass[i][j]);
      }
    }

    printf("%d\n", ans);
  }


  return 0;
}




Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long ll;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int n;
    cin >> n;
    map<string, int> ans;
    int count = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ans[s]++;
        count = max(count, ans[s]);
    }
    for (auto x : ans) {
        if (x.second == count) cout << x.first << endl;
    }
}


Measured memory_bytes: 19072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h, w;
		String a[];
		h = sc.nextInt();
		w = sc.nextInt();
		a = new String[h];
		for(int i = 0; i < h; ++i) {
			a[i] = sc.next();
		}
		sc.close();
		
		for(int i = -1; i < h + 1; ++i) {
			for(int j = -1; j < w + 1; ++j) {
				if(i == -1 || i == h || j == -1 || j == w)System.out.print("#");
				else System.out.print(a[i].charAt(j));
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 27248
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    A,B,H,M = [int(x) for x in stdin.readline().rstrip().split()]
    m_deg = M * 6
    h_deg_kari = (H * 30) + (M * 0.5)
    h_deg = min(abs(h_deg_kari - m_deg), 360 - abs(h_deg_kari - m_deg))
    
    if h_deg == 0:
        print(abs(A-B))
    elif h_deg == 180:
        print(A+B)
    else:
        print(math.sqrt(A ** 2 + B ** 2 - (2 * A * B * math.cos(math.radians(h_deg)))))
    
main()

Measured memory_bytes: 10292
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = t.size();

    string ans;
    for(int i=0; i<n; ++i){
        ans += s[i];
        ans += t[i];
    }
    if(s.size() != n)
        ans += s[n];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 5005;

int n, K, a[mxn];
bitset<mxn> pre[mxn], suf[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> n >> K;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    pre[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        pre[i] = pre[i-1] | (a[i] >= K ? 0 : pre[i-1]<<a[i]);
    }
    suf[n+1][0] = 1;
    for (int i = n; i >= 1; i--) {
        suf[i] = suf[i+1] | (a[i] >= K ? 0 : suf[i+1]<<a[i]);
    }

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= K) continue;
        vector<int> v;
        for (int j = 0; j < K; j++) {
            if (suf[i+1][j]) v.push_back(j);
        }
        bool ok = 0;
        for (int j = 0; j < K; j++) {
            // for (int k = max(K-a[i], j); k <= K-1; k++) {
            //     ok |= pre[i-1][j] and suf[i+1][k-j];
            // }
            if (pre[i-1][j]) {
                auto it = lower_bound(begin(v), end(v), max(K-a[i], j)-j);
                if (it != end(v) and *it <= K-1-j) {
                    ok = 1;
                    break;
                }
            }
        }
        cnt += !ok;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 6528
A, B = map(int, input().split())
 
# floor(1009*0.1)=100 かつ floor(1010*0.1)=101 より、1から1009までの数字を調べればよい
ans = '-1'
for i in range(1010):
  if i*8 // 100 == A and i // 10 == B:
    ans = i
    break

print(ans)

Measured memory_bytes: 9152
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N; cin.ignore();

  string str;
  getline(cin, str);
  stringstream ss(str);
  vector<int> a_vec;
  for (int i; !ss.eof();){
    ss >> i;
    a_vec.push_back(i);
  }

  unordered_map<int, int> um;
  for (size_t index=0; index<N; index++) {
    for (int i=a_vec[index]-1; i<=a_vec[index]+1; i++) {
      if (um.count(i) == 0) {
        um[i] = 1;
      } else {
        um[i]++;
      }
    }
  }

  int ans = 0;
  for(auto it = um.begin(); it!=um.end(); it++) {
    if( ans < it->second ) ans = it->second;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int x[MAX];

 main() {
    int n, a, b;
    cin >> n >> a >> b;
    REP(i, n) cin >> x[i];
    int ret = 0;

    for(int i=1;i<n;i++){
      int d = (x[i]-x[i-1])*a;
      if(d < b) ret += d;
      else ret += b; 
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
        char s[11];
        int n, i, j, z;
        int min = 999;

        scanf("%s", s);

        n = strlen(s);
        for(i=0; i<n-2; i++){
                z = 0;
                for(j=0; j<3; j++){
                        z = z*10 + (s[i+j] - '0');
                }
                if(abs(z-753)<min)      min = abs(z-753);
        }
        printf("%d\n", min);
        return 0;
}

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

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

int main(){
  int ans = 0,N;
  cin >> N;
  vector<int> A(N),M(N),L(N+1),R(N+1);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    if(i == 0)L[i]=0;
    L[i+1] = gcd(L[i],A[i]);
  }
  for(int i=N-1;i>=0;i--){
    R[N]=0;
    R[i] = gcd(R[i+1],A[i]);
    M[i] = gcd(L[i],R[i+1]);
  }
  sort(M.begin(),M.end());
  cout << M[N-1] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;
const int N = 1e5+1;
using ll = long long;
char buf[N];
unordered_map<string, int> m;

void deal(){
	sort(buf, buf+10);
	++m[buf];
}

int main(){
	int n;
	scanf("%d", &n);
	while(n--){
		scanf("%s", buf);
		deal();
	}
	ll ans = 0;
	for(auto &kv: m){
        ll v = kv.second;
		ans += v*(v-1)/2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10660
import java.util.Scanner;

public class Main {

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

		char[] ch = N.toCharArray();
		int f = 0;
		for(int i = 0;i < ch.length;i++) {
			f += Character.getNumericValue(ch[i]);
		}
		System.out.println(Integer.parseInt(N)%f == 0 ? "Yes" : "No");
	}
}

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

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

    int n;
    cin >> n;
    
    int cnt = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(a % 2) continue;
        while(true){
            cnt++;
            a /= 2;
            if(a % 2) break;
        }
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long cnt = 0;
		
		if (a % x == 0) cnt++;
		cnt += b / x - a / x;
		System.out.println(cnt);
	}
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

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

int depth[1<<20];
vector<int> c[1<<20];

int get(int v) {
  int res = c[v].size();
  vector<int> f;
  for (int& k: c[v]) f.pb(get(k));
  sort(f.rbegin(), f.rend());
  REP(i,f.size()) res = max(res, f[i]+i+1);
  return res;
}

int main() {
  int N;
  scanf("%d", &N);
  FOR(i,1,N) {
    int a;
    scanf("%d", &a);
    c[--a].pb(i);
  }
  int result = get(0);
  printf("%d\n", result);
}


Measured memory_bytes: 38912
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

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

    int l[1000];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int a = 0;
    int i = 0;

    for (i = 0; i < n; i++) {
        a += l[i];
        if (a > x) {
            break;
        }
    }

    cout << i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
def binarySearch (arr, l, r, x): 
  
    # Check base case 
    if r >= l: 
  
        mid = l + (r - l) // 2
  
        # If element is present at the middle itself 
        if arr[mid] == x: 
            return mid 
          
        # If element is smaller than mid, then it  
        # can only be present in left subarray 
        elif arr[mid] > x: 
            return binarySearch(arr, l, mid-1, x) 
  
        # Else the element can only be present  
        # in right subarray 
        else: 
            return binarySearch(arr, mid + 1, r, x) 
  
    else: 
        # Element is not present in the array 
        return -1

l=list(map(int, input().split(' ')))

find=l[0]
n=l[1]

if n==0:
    print(find)
else:
    l=list(map(int, input().split(' ')))
    l=sorted(l)

    a=find
    b=find
    
    while True:
        if binarySearch(l, 0, n-1, b)==-1:
            print(b)
            break
        elif binarySearch(l, 0, n-1, a)==-1:
            print(a)
            break
        else:
            a+=1
            b-=1
        




Measured memory_bytes: 62144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;


int main(){
    Int A, B, N; cin >> A >> B >> N;

    Int ans;
    if(B-1 <= N) ans = A*(B-1)/B - A*((B-1)/B);
    else ans = A*N/B - A*(N/B);
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  ll n;
  cin>>n;
  vector<ll> V(n+1,0);
  for(ll i=1;i<=n;i++)
  {
    for(ll j=i;j<=n;j+=i)
    V[j]++;
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
  {
    ans=ans+(V[i]*i);
  }
  cout<<ans<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 81344
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


# nの約数を列挙列挙する
def make_divisors(n):
    divisors = []
    for i in range(1, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


def resolve():
    n = int(input())

    div = make_divisors(n)

    res = f_inf
    for i in div:
        cost = i + n // i - 2
        res = min(res, cost)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3268
#include <iostream>
#include <numeric>

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

int main() {
  int n, k;
  std::cin >> n >> k;

  int *a = new int[n + 1];
  rep(i, n + 1) a[i] = i;

  long long sum = 0;

  for (long long i = k; i <= n + 1; ++i) {
    long long min = i * (i - 1) / 2;
    long long max = i * (2 * n - i + 1) / 2;

    long long m = max - min + 1;

    sum += m;
  }

  std::cout << sum % (1000000000 + 7) << '\n';

  return 0;
}


Measured memory_bytes: 4284
#include <cstdio>

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// 整数の個数(2≦N≦50)

int main () {

	int x, diff = 0;

	// 整数の数の読込み
	scanf("%d", &N);

	for(int i = 1; i <= N; i++) { 
		scanf("%d", &x);
		if(x != i) diff ++;
	}

	if(diff <= 2) printf("YES\n");
	else printf("NO\n");

	return 0;
}

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

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

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)

int a,b,c,k;

int main(){

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

	cin>>a>>b>>c>>k;

	while(k--){
		if(a >= b){
			b *= 2;
			continue;
		}
		else if(b >= c){
			c *= 2;
			continue;
		}
		else{
			break;
		}
	}

	if(c > b && b > a){
		cout<<"Yes";
		return 0;
	}

	cout<<"No";

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k;
  cin >> k;
  int cnt=0;
  rep(i,n){
    int a;
    cin >> a;
    if(a>=k)cnt++;
  }
  
 cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define eb pb
#define rep(X,Y) for(int X=0;X<(Y);++X)
#define reps(X,O,Y) for(int X=O;X<(Y);++X)
#define all(X) (X).begin(),(X).end()
using namespace std;
using ll=long long;
const ll MOD=1e9+7;

map<int,int> dp[112345];

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	dp[0][-MOD]=dp[0][MOD]=0;
	auto upd=[&](map<int,int> &nxt,int a,int b){
						 if(nxt.count(a)==0 || nxt[a]>b) nxt[a]=b;
					 };
	auto ok=[](int a,int b,int c){ return(a<b)!=(b<c);};
	rep(i,n-1){
		assert(dp[i].size()<10);
		for(auto p:dp[i]){
			if(ok(p.X,a[i],a[i+1])){
				upd(dp[i+1],a[i],p.Y);
			}
			if((p.X<a[i])==(p.X<a[i+1]) && ok(p.X,a[i+1],a[i])){
				if(i+2==n || ok(a[i+1],a[i],a[i+2])) upd(dp[i+2],a[i],p.Y+1);
			}
			if(i+2<n && ok(p.X,a[i],a[i+2]) && ok(a[i],a[i+2],a[i+1])){
				if(i+3==n || ok(a[i+2],a[i+1],a[i+3])) upd(dp[i+3],a[i+1],p.Y+1);
			}
		}
	}
	int re=MOD;
	for(auto p:dp[n-1]) re=min(re,p.Y);
	for(auto p:dp[n]) re=min(re,p.Y);
	cout<<re<<endl;
}



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

int main(){
   int N,M;
   cin >> N >> M;
   int ans = 0;
   vector<vector<bool>> table(10,vector<bool>(10));
   int K[10];
   for(int i = 0;i < M;i++){
       int k;
       cin >> k;
       K[i] = k;
       for(int j = 0;j < k;j++){
           int a;
           cin >> a;
           table[i][a-1] = true;
       }
   }
   int List[10];
   for(int i = 0;i < M;i++){
       cin >> List[i];
   }
   int n = pow(2,N);
   for(int i = 0;i < n;i++){
       vector<int> X(10,0);
       int t = i;
       for(int j = 0;j < i;j++){
           X[j] = t % 2;
           t = (t - t % 2) / 2;
           if(t == 0){
               break;
           }
       }
       bool judge = true;
       for(int k = 0;k < M;k++){
           int cnt = 0;
           for(int o = 0;o < N;o++){
               if(table[k][o]){
                   if(X[o] == 1){
                       cnt++;
                   }
               }
           }
           if(cnt % 2 != List[k]){
               judge = 0;
           }
       }
       if(judge){
           ans++;
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
class UnionFindTree():
    def __init__(self, N):
        self.N = N
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(self.N):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, M = map(int, input().split())
    uft = UnionFindTree(N)
    for _ in range(M):
        A, B = map(int, input().split())
        uft.unite(A-1, B-1)
    ans = 0
    for g in uft.groups():
        ans = max(ans, len(g))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 122200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        String a = sc.nextLine();
        String lowercase = a.toLowerCase();
        return a.equals(lowercase) ? "a" : "A";
    }
}


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

int main()
{
    set<int> s;
    int n, m;

    cin >> n;
   
    int a;

    for( int i = 0; i < n; i++ )
    {
        cin >> a;
        s.insert(a);
    }

    cin >> m;

    for( int i = 0; i < m; i++ )
    {    
        cin >> a;
        s.insert(a);
    }

    for( set<int>::iterator itr = s.begin(); itr != s.end(); itr++ )
        cout << *itr << endl;

    return 0;
}


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

using namespace std;

int pow(int b, int p) {
    int tmp = 1;
    for (int c = 0; c < p; c++) {
        tmp *= b;
    }
    return tmp;
}

int main(){
    int x, ans=1;
    cin >> x;
    for(int b=1;b<=x;b++){
        for(int p=2;p<=x;p++){
            int power=pow(b,p);
            if(power>x) break;
            ans=max(ans,power);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void) {

  double k;
  double a, b;

  cin >> k;
  cin >> a >> b;

  int low = ceil(a/k);
  int high = b/k;
  
  if(low <= high)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  
  
  return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
main()
{
	register long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld",max(max(a*c,a*d),max(b*c,b*d)));
}

Measured memory_bytes: 1736
S = input()
T = input()

lstS = list(S)
lstT = list(T)

difMin = 1000

for i in range(len(lstS)-len(lstT)+1):
  dif = 0
  
  for j in range(len(lstT)):
    if(lstT[j] != lstS[i+j]):
      dif += 1
  
  if(dif < difMin):
    difMin = dif

print(difMin)

Measured memory_bytes: 9012
import java.util.Scanner;

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




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

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

    char c; cin>>c;
    if(c-'A'>=0 and c-'Z'<=0) cout << "A" << "\n";
    else cout << "a" << "\n";
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))


def gcd(a,b):
  x = max([a,b])
  y = min([a,b])
  while y:
    x, y = y, x % y
  return x

L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[-1], A[i]))
    
for i in reversed(range(N)):
    R.append(gcd(R[-1], A[i]))

R = list(reversed(R))


ans = 1
for i in range(N-1):
    ans = max(ans, gcd(L[i], R[i+1]))

ans = max(ans, R[1])
ans = max(ans, L[-2])

print(ans)
#print(R)
#print(L)

Measured memory_bytes: 14524
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        
        if(checkM(m)){
            return;
        }
        if(n>m)
        {
            System.out.println(0);
            return;
        }
        
        int[] x = new int[m];
        for(int i=0;i<x.length;i++)
        {
            x[i] = scan.nextInt();
        }
        
        Arrays.sort(x);
        int[] y = new int[m-1];
        for(int i=0;i<y.length;i++)
        {
            y[i] = Math.abs(x[i+1] - x[i]);
            // System.out.print(y[i]);
        }
        Arrays.sort(y);
        int ans = x[m-1]-x[0];
        int count = 1;
        while(count<n)
        {
            ans -= y[m-1-count];
            count++;
        }
        System.out.println(ans);
        
    }
    
    static boolean checkM(int m)
    {
        if(m==1)
        {
            System.out.println(0);
            return true;
        }
        
        return false;
    }
}

Measured memory_bytes: 49812
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;

void solve()
{
	int n, k; cin >> n >> k;
	long double ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (i >= k) ans += 1;
		else
		{
			int flips = 0, cur = i;
			while (cur < k)
			{
				++flips;
				cur *= 2;
			}
			ans += powl(2, -flips);
		}
	}
	ans /= (1.0 * n);
	cout << fixed << setprecision(15) << ans;
}

//  ---------------------Template---------------------------
void InputSetup()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
}

int main(void)
{
	auto start = chrono::high_resolution_clock::now();

	InputSetup();
	solve();

	auto finish = chrono::high_resolution_clock::now();
	cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
}
//  ---------------------Template---------------------------

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

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

  int n,m;
  cin >> n >> m;
  ll x[n],y[m];
  rep(i,n) cin>>x[i];
  rep(j,m) cin>>y[j];

  ll xsum=0;
  ll ysum=0;
  rep(i,n-1){
    xsum=ad(xsum, mu(mu(x[i+1]-x[i],n-i-1),i+1));
  }
  rep(j,m-1){
    ysum=ad(ysum, mu(mu(y[j+1]-y[j],m-j-1),j+1));
    //    cout << ysum << endl;
  }
  cout << mu(xsum,ysum) << endl;
  
  return 0;
    

}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  int hh, w, t, p;
  while (cin >> w >> hh >> t >> p, w) {
    int res[40][40];
    for (int i = 0; i < 40; i++) for (int j = 0; j < 40; j++) res[i][j] = 0;
    for (int i = 0; i < hh; i++) for (int j = 0; j < w; j++) res[i][j] = 1;
    for (int ii = 0; ii < t; ii++) {
      int d, c; cin >> d >> c;
      int tmp[40][40];
      for (int i = 0; i < 40; i++) for (int j = 0; j < 40; j++) tmp[i][j] = 0;
      if (d == 1) {
        // d == 1
        for (int i = 0; i < 40; i++) {
          for (int j = c; j < 40; j++) {
            tmp[i][j - c] += res[i][j];
          }
        }
        for (int i = 0; i < 40; i++) {
          for (int j = c - 1; j >= 0; j--) {
            tmp[i][c - 1 - j] += res[i][j];
          }
        }
      } else {
        // d == 2
        int h = 0;
        for (int i = 0; i < 40; i++) {
          if (res[i][0] != 0) h++;
        }
        if (c >= h - c) {
          for (int i = h - 1; i >= h - c; i--) {
            for (int j = 0; j < 40; j++) {
              tmp[h - 1 - i][j] += res[i][j];
            }
          }
          for (int i = 0; i < h - c; i++) {
            for (int j = 0; j < 40; j++) {
              tmp[i + 2 * c - h][j] += res[i][j];
            }
          }
        } else {
          for (int i = 0; i < h - c; i++) {
            for (int j = 0; j < 40; j++) {
              tmp[i][j] += res[i][j];
            }
          }
          int now = c;
          for (int i = h - 1; i >= h - c; i--) {
            for (int j = 0; j < 40; j++) {
              tmp[i - 2 * now + 1][j] += res[i][j];
            }
            now--;
          }
        }
      }
      //tmp -> res
      for (int i = 0; i < 40; i++) {
        for (int j = 0; j < 40; j++) {
          res[i][j] = tmp[i][j];
        }
      }
      // for (int i = 0; i < 10; i++) {
      //   for (int j = 0; j < 10; j++) {
      //     cerr << res[i][j];
      //   }
      //   cerr << endl;
      // }
    }
    // ans
    int hlen = 0;
    for (int i = 0; i < 40; i++) {
      if (res[i][0] != 0) hlen++;
    }
    for (int i = 0; i < p; i++) {
      int x, y; cin >> x >> y;
      cout << res[hlen - 1 - y][x] << endl;
    }
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
 
int main(){
  int c[3][3]={};
  int c11;
  bool correct = true;

  for (int i=0;i<3;i++){
    for (int j=0;j<3;j++){
      cin >> c[i][j];
      if (i==0 && j==0) c11 = c[0][0];
      c[i][j] -= c11;
      if (c[i][j] != c[i][0] + c[0][j]) correct = false;
    }
  }
  
  cout << (correct? "Yes" : "No") << endl;


}
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  
  return i;
}
bool judge(string s){
  bool ret = false;
  string t = s;
  reverse(t.begin(), t.end());
  if(s == t){
    ret = true;
  }
  return ret;
}

void solve(){
  int n = 3;
  int a[n][n];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cin >> a[i][j];
    }
  }
  int h;
  cin >> h;
  int b;
  for(int i = 0;i < h;i++){
    cin >> b;
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
        if(b == a[i][j]) a[i][j] = 0;
      }
    }
  }
  int c = 0;
  for(int i = 0;i < n;i++){
    int t = a[i][0];
    for(int j = 1;j < n;j++){
      if(t == a[i][j]) c++;
    }
    if(c == 2) break;
    else c = 0;
  }
  int d = 0;
  for(int i = 0;i < n;i++){
    int t = a[0][i];
    for(int j = 1;j < n;j++){
      if(t == a[j][i]) d++;
    }
    if(d ==2) break;
    else d = 0;
  }
  if(c==2||d==2||(a[1][1]==a[0][0]&&a[0][0]==a[2][2])||(a[2][0]==a[1][1] &&a[1][1]==a[0][2]))
  cout << "Yes" << endl;
  else cout << "No" << endl;
}


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


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

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    vector<ll> dp(1100000, INF);

    // 初期条件
    dp[0] = 0;
    // ループ
    for (ll i = 0; i < 110000; i++) {
        for(ll j = 0; j < N; j++) {
            if(dp[i]!=INF)chmin(dp[i + A[j]], dp[i] + B[j]);
        }
    }

    //答え
    ll min_num = INF;
    for(ll i = H; i<H+10000; i++) {
        if(dp[i]!=INF) {
            min_num = min(dp[i], min_num);
        }
    }
    cout << min_num << endl;
    return 0;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main(void) {
    int N, C;
    vector<long long> A;

    C = 0;
    cin >> N;
    for (int i=0;i<N;i++) {
        long long X;
        cin >> X;
        if (X<0) C++;
        A.push_back(abs(X));
    }

    if (C%2) cout << accumulate(A.begin(), A.end(), 0LL) - 2LL*(*min_element(A.begin(), A.end())) << endl;
    else cout << accumulate(A.begin(), A.end(), 0LL) << endl;

    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int n = Integer.parseInt(scan.next());
	int[] a = new int[n];
	int[] e;
	int[] o;
	if(n % 2 == 0) {
	    e = new int[n/2];
	    o = new int[n/2];
	}
	else {
	    e = new int[n/2+1];
	    o = new int[n/2];
	}
	for (int i = 0; i < n; i++) {
	    if(i % 2 == 0) e[i/2] = Integer.parseInt(scan.next());
	    else o[i/2] = Integer.parseInt(scan.next());
	}

	if(n % 2 == 0) {
	    int length = n/2;
	    for (int i=0; i < length; i++) a[i] = o[length-1-i];
	    for (int i=0; i < length; i++) a[i+length] = e[i];
	    
	} else {
	    int length = n/2 + 1;
	    for (int i=0; i<length; i++) a[i] = e[length-1-i];
	    for (int i=0; i<length-1; i++) a[i+length] = o[i];
	}

	for (int i = 0; i < n; i++) {
	    if(i == 0) System.out.print(a[i]);
	    else System.out.print(" " + a[i]);
	}
	scan.close();
    }
}


Measured memory_bytes: 67140
#include<iostream>
#include<bitset>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	
	int n;
	while(cin>>n){
		bitset<2001*2001>bs;
		int sum=0,temp;
		bs[0]=1;
		for(int i=1;i<=n;i++){
			cin>>temp;
			sum+=temp;
			bs|=bs<<temp;
		}
		sum++; 
		for(int i=(sum/2);;i++){
			if(bs[i]){
				cout<<i<<endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  int ans=0;
  vector<vector<int>> A(10,vector<int>(10));
  for(int i=0;i<=N;i++){
    string S=to_string(i);
    A[S[0]-'0'][S[S.size()-1]-'0']++;
  }
  for(int i=1;i<10;i++)
    for(int j=1;j<10;j++)
      ans+=A[i][j]*A[j][i];
  cout<<ans<<endl;
}

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

typedef long long ll;
#define MOD 1000000007

int main(){

    int n,m; cin >> n >> m;
    vector<ll> x(n),y(m);

    for(int i=0; i<n; i++ ) cin >> x[i];
    for(int i=0; i<m; i++ ) cin >> y[i];

    ll sumR = 0, sumC = 0;
    for(ll i=1; i<=n; i++ ){
        sumR += (x[i-1]*(i-1) - x[i-1]*(n-i));
        sumR %= MOD;
    }
    for(ll i=1; i<=m; i++ ){
        sumC += (y[i-1]*(i-1) - y[i-1]*(m-i));
        sumC %= MOD;
    }

    cout << (sumR * sumC) % MOD << endl;

    return 0;
}


Measured memory_bytes: 1792
S = input()
def kaibun_check(bun):
    if bun == bun[::-1]:
        return True
    else:
        return False
if kaibun_check(S):
    idx = int((len(S) -1)/2)
    if kaibun_check(S[:idx]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#coding utf-8
import math
import copy
n = int(input())
m = copy.copy(n)
A = []

for i in range(2,int(math.sqrt(m))+2):
    if n == 1:
        break
    if n % i == 0:
        while n % i == 0:
            A.append(str(i))
            n //= i
if n > 1:
    A.append(str(n))
print(str(m) + ': ' + ' '.join(A))


Measured memory_bytes: 6376
#!/usr/bin/env python3
 
import sys
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()


def main():
    input = sys.stdin.readline      # 改行文字が残ることに注意
    def ii():  return int(input())
            

    def bfs_tree_traverse(root):
        ' root から BFS し条件を満たすように彩色していく。各辺の色情報を color に記載。最後に使用した色の数を返す。'
        paths = deque([root])
        max_branch = 0
        while len(paths) != 0:
            edge_color = 0
            current = paths.popleft()
            parent_edge_color = color[current]
            for v in adj[current]:
                paths.append(v)
                edge_color += 1
                if edge_color == parent_edge_color:
                    edge_color += 1
                color[v] = edge_color
                max_branch = max(max_branch, edge_color)
        return max_branch
        
 
    n = ii()
    # 各辺の両端の頂点 index を保存したペア (tuple) の list
    L = [tuple(map(lambda x: int(x)-1, input().rstrip().split())) for _ in range(n-1)]
    # 隣接リスト 親->子のみリンクをはれば十分
    adj = [[] for _ in range(n)]
    for pair in L:
        a, b = pair
        adj[a].append(b)
    # 各辺の子供の index と色情報 (int) の対応記載される隣接行列 
    color = [0] * n
    
    print(bfs_tree_traverse(0))
    for pair in L:
        _, b = pair
        print(color[b])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 28076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int a[100010],b[100010],t[100010],m[100010],v[100010];
int main() {
    int n;
    cin>>n;
    int l,r,mm=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    ll ans=1;
    for(int i=1;i<=n;i++){
        if((a[i]>a[i-1]&&b[i]<a[i])||(b[i]>b[i+1]&&b[i]>a[i])) ans=0;
        else if(a[i]==a[i-1]&&b[i]==b[i+1])ans=ans*min(a[i],b[i])%mod;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024