akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i,n){
    cin >> x[i];
  }
  ll ans = 0;
  srep(i,1,n){
    ll diff = a*(x[i]-x[i-1]);
    if(diff<b) ans+=diff;
    else ans+=b;
  }
  cout<<ans<<endl;
  return 0;
}

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

int h, w, white;
char a[50][50];
bool b[50][50];

struct node{
    int i=0;
    int j=0;
    int d=0;
    node(int _i, int _j, int _d): i(_i), j(_j), d(_d){};
};

int bfs(int i, int j){
    queue<node> n;
    n.push(node{i,j,1});
    while(!n.empty()){
        node s = n.front();
        n.pop();
        if(s.i == h-1 && s.j == w-1) return s.d;
        int ni = s.i;
        int nj = s.j;
        if(ni>=0 && ni<h-1 && nj >=0 && nj < w  && a[ni+1][nj] == '.' && !b[ni+1][nj]) b[ni+1][nj] = true, n.push(node{ni+1, nj, s.d+1});
        if(ni>=0 && ni<h && nj >=0  && nj < w-1 && a[ni][nj+1] == '.' && !b[ni][nj+1]) b[ni][nj+1] = true, n.push(node{ni, nj+1, s.d+1});
        if(ni>0  && ni<h && nj >=0  && nj < w   && a[ni-1][nj] == '.' && !b[ni-1][nj]) b[ni-1][nj] = true, n.push(node{ni-1, nj, s.d+1});
        if(ni>=0 && ni<h && nj >0   && nj < w   && a[ni][nj-1] == '.' && !b[ni][nj-1]) b[ni][nj-1] = true,n.push(node{ni, nj-1, s.d+1});
    }
    return -1;
}

int main()
{
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
            if(a[i][j] == '.') white++;
        }
    }
    int ans = bfs(0, 0);
    if(ans != -1){
        cout << white - ans << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

bool D[10];
bool isValid(int x){
	for(int d=x;d>0;d/=10){
		if(D[d%10]) return true;
	}
	return false;
}

int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	for(int i=0;i<K;i++){
		int d;
		scanf("%d",&d);
		D[d]=true;
	}
	int i;
	for(i=N;isValid(i);i++);
	printf("%d\n",i);
}

Measured memory_bytes: 128
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn add(v: &mut Vec<String>, cnt: &mut Vec<i32>, S: String, X: i32){
    let len = v.len();
    for i in 0..len {
        if v[i] == S {
            cnt[i] += X;
            return;
        }
    }
    v.push(S);
    cnt.push(X);
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();
    let mut v = Vec::new();
    let mut cnt = Vec::new();

    let N = read::<i32>();
    for n in 0..N {
        let S = read::<String>();
        add(&mut v, &mut cnt, S, 1);
    }
    let M = read::<i32>();
    for n in 0..M {
        let S = read::<String>();
        add(&mut v, &mut cnt, S, -1);
    }

    cnt.sort();
    cnt.reverse();
    let m = {
        if cnt[0] < 0 {
            0
        } else {
            cnt[0]
        }
    };
    println!("{}", m);


}


Measured memory_bytes: 4352
N, A, B = gets.split.map(&:to_i)
count = 0
1.upto(N) do |i|
  pre = i.to_s.split('').map(&:to_i)
  pre2 = pre.inject(:+)
  if A <= pre2 && pre2 <= B
    # p pre
    count += i
  end
end
puts count


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll kk;
	cin>>kk;
	ll cnt[100000]={0};
	for(ll i=1;i<=100;i++)
	{
		for(ll j=1;j<=100;j++)
		{
			for(ll k=1;k<=100;k++)
			{
				ll temp=(i*i)+(j*j)+(k*k)+(i*j)+(i*k)+(j*k);
				cnt[temp]++;
			}
		}
	}
	for(ll i=1;i<=kk;i++) cout<<cnt[i]<<endl;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data_r(N);
  for (int &e : data_r) cin >> e;
  
  vector<int> data_s = data_r;
  sort(data_s.begin(), data_s.end());
  int L = data_s[N/2-1];
  int R = data_s[N/2];
  
  for (int i = 0; i < N; i++) {
    if (data_r[i] >= R) cout << L << endl;
    else cout << R << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N,Q;
	int i,j;
	int counter=0;
	ll tmp;
	ll before,after;
	ll answer=0;
	ll maximum=0;
	vector<ll> data(100000+10);
	vector<pair<ll,ll>> given;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		data[tmp]++;
		answer+=tmp;
	}

	cin >> Q;

	for(i=0;i<Q;i++){
		cin >> before >> after;

		answer+=(after-before)*data[before];
		data[after]+=data[before];
		data[before]=0;
	
		cout << answer << endl;
	}

	return 0;
}



Measured memory_bytes: 3916
#include <cstdio>
#include <numeric>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> graph;
vector<long long> dat;


vector<int> death; // 0: undecided, 1: dead

int main() {
	int n;
	scanf("%d",&n);
	dat.resize(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld",&dat[i]);
	}
	graph.resize(n);
	for (int i = 0; i < n-1; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		a--,b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	vector<pair<int,int>> sp;
	for (int i = 0; i < n; i++) {
		sp.emplace_back(dat[i], i);
	}
	sort(sp.begin(),sp.end());

	death.resize(n);

	for (int i = 0; i < n; i++) {
		int cur = sp[i].second;
		bool won = false;
		for (auto next : graph[cur]) {
			if (dat[next] < dat[cur]) {
				if (death[next] == 1) {
					won = true;
				}
			}
		}
		if (won) {
			death[cur] = 0;
		} else {
			death[cur] = 1;
		}
	}

	vector<int> ans;
	for (int i = 0; i < n; i++) {
		if (death[i] == 0)
			ans.push_back(i+1);
	}
	for (int i = 0; i < ans.size(); i++){
		if (i > 0) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;

	cout << N - K + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=2e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int pexp[MAX];
int main() 
{

	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int a, b, c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int tot=0;
    while(c<=b){
    	c=c*2;
    	tot=tot+1;
    }
    while(c<=a)
    {
    	c=c*2;
    	tot=tot+1;
    }
    while(b<=a){
    	b=b*2;
    	tot=tot+1;
    }
    while(c<=b)
    {
    	c=c*2;
    	tot=tot+1;
    }
   // cout<<tot;
   // cout<<a<<b<<c;
    if(tot>k)
    	cout<<"No";
    else
    	cout<<"Yes";

}

Measured memory_bytes: 3644
a,b,k = map(int,input().split())
x = [x for x in range(1,a+1) if a % x == 0]
x.sort(reverse=True)
y = [x for x in range(1,b+1) if b % x == 0]
y.sort(reverse=True)

cnt = 0
for i in range(len(x)):
    if x[i] in y:
        cnt += 1
    if cnt == k:
        print(x[i])
        exit()

Measured memory_bytes: 3064
h,w,d=map(int,input().split())

a={}
for y in range(h):
    tmp=list(map(int,input().split()))

    for x,v in enumerate(tmp):
        a[v]=(y,x)

dis=[0]*(h*w+1)

#dis[j]=j%dからjまでのコスト

for i in range(1,h*w+1):
    if i>d:
        bk=a[i-d]
        nx=a[i]
        dis[i]=dis[i-d]+abs(bk[0]-nx[0])+abs(bk[1]-nx[1])

q=int(input())
ans=[]
for _ in range(q):
    start,goal=map(int,input().split())
    ans.append(dis[goal]-dis[start])

for item in ans:
    print(item)





Measured memory_bytes: 89096
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int a, b, c;
int main() {
	cin >> a >> b >> c;
	if (a < b) swap(a, b);
	if (a < c) swap(a, c);
	if (b < c) swap(b, c);
	if ((b - c) % 2 == 0) {
		cout << (b - c) / 2 + (a - b) << endl;
	}
	else {
		cout << (b - c + 1) / 2 + (a - b + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endk '\n'

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

  int n;
  cin >> n;
  map<string, long long> s;
  string entra;
  unsigned long long ans = 0;
  while (n--) {
    cin >> entra;
    sort(entra.begin(), entra.end());
    if (s.count(entra)) s[entra]++;
    else s.insert({entra, 1});
  }
  for (auto x : s) {
    //cout << "x.first " << x.first << "x.second " << x.second << endk;
    ans += (x.second*(x.second-1))/2; 
  }
  cout << ans << endk;
  return 0;}


Measured memory_bytes: 11264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  public static void solve() {
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int[] deg = new int[n];
    List<List<Integer>> edges = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      edges.add(new ArrayList<>());
    }
    for (int x, y, i = 0; i < m; i++) {
      x = scanner.nextInt() - 1;
      y = scanner.nextInt() - 1;
      deg[y]++;
      edges.get(x).add(y);
    }
    Queue<Integer> queue = new ArrayDeque<>();
    for (int i = 0; i < n; i++) {
      if (deg[i] == 0) {
        queue.add(i);
      }
    }
    int[] dist = new int[n];
    while (!queue.isEmpty()) {
      int u = queue.poll();
      for (int v : edges.get(u)) {
        dist[v] = Math.max(dist[v], dist[u] + 1);
        deg[v]--;
        if (deg[v] == 0) {
          queue.add(v);
        }
      }
    }
    int result = 0;
    for (int i = 0; i < n; i++) {
      result = Math.max(result, dist[i]);
    }
    printer.println(result);
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


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

struct data
{
    int u,v;
    char type;
};

data a[100005];
int n,k,res=0,f[1005][2][2];

void Process()
{
    for(int i=0; i<=k; i++)
    {
        for(int j=0; j<k; j++)
        {
            f[j][0][0]=0;
            f[j][0][1]=0;
            f[j][1][0]=0;
            f[j][1][1]=0;
        }
        int Count=0;
        for(int j=1; j<=n; j++)
            if(((a[j].u-i)/k+a[j].v/k)%2==0)
            {
                if(a[j].type=='W')
                {
                    Count++;
                    f[a[j].v%k][0][0]++;
                }
                else
                    f[a[j].v%k][0][1]++;
            }
            else
            {
                if(a[j].type=='B')
                {
                    Count++;
                    f[a[j].v%k][1][1]++;
                }
                else
                    f[a[j].v%k][1][0]++;
            }
        res=max(res,max(Count,n-Count));
        for(int j=0; j<k; j++)
        {
            Count-=f[j][0][0]+f[j][1][1];
            Count+=f[j][0][1]+f[j][1][0];
            res=max(res,max(Count,n-Count));
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("TEST.INP","r",stdin);
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i].u>>a[i].v>>a[i].type;
        a[i].u+=k;
        a[i].v+=k;
    }
    Process();
    cout<<res;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
    
        int a = 0;
        while(a < n){
            a += 1000;
        }
        System.out.println(a - n);
    }
}

Measured memory_bytes: 35736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b,c; cin >> a >> b>>c;
	cout << a * b / 2;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

INF = float("inf")

N, *A = map(int, open(0).read().split())

dp = defaultdict(lambda: -INF)
dp[(0, 0, False)] = 0

for i, a in enumerate(A, 1):
    p = i // 2
    for j in [p - 1, p, p + 1]:
        dp[(i, j, True)] = a + dp[(i - 1, j - 1, False)]
        dp[(i, j, False)] = max(dp[(i - 1, j, False)], dp[(i - 1, j, True)])

print(max(dp[(N, N // 2, True)], dp[(N, N // 2, False)]))

Measured memory_bytes: 300136
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int D = sc.nextInt();
        int[][] X = new int[N][D];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < D; ++j) {
                X[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int[][] X) {
        int result = 0;
        for (int i = 0; i < X.length; ++i) {
            for (int j = i + 1; j < X.length; ++j) {
                int distanceSquare = computeDistanceSquare(X[i], X[j]);
                int distance = (int) Math.round(Math.sqrt(distanceSquare));
                if (distance * distance == distanceSquare) {
                    ++result;
                }
            }
        }

        return result;
    }

    static int computeDistanceSquare(int[] v1, int[] v2) {
        return IntStream.range(0, v1.length).map(i -> (v1[i] - v2[i]) * (v1[i] - v2[i])).sum();
    }
}

Measured memory_bytes: 36524
#include<iostream>
#include<string>
#include<map>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
// for (int i = 0; i < N; ++i) cin >> A[i];
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<string, int> mapii;

int main () {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        out("Yes")
    }
    else {
        out("No")
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> POINT;

int main()
{
	//ifstream ifs("data.txt");

	int n;
	while( cin >> n && n){
		vector<POINT> points;
		ll res = 0;

		//INPUT
		for(int i = 0; i < n; i++)
		{
			POINT pos;
			cin >> pos.first >> pos.second;
			points.push_back(pos);
		}

		sort(points.begin(), points.end());
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				POINT pos1, pos2;
	
				pos1.first	= points[i].first - (points[j].second - points[i].second);
				pos1.second	= points[i].second + (points[j].first - points[i].first);
				pos2.first	= points[j].first - (points[j].second - points[i].second);
				pos2.second	= points[j].second + (points[j].first - points[i].first);

				if(binary_search(points.begin(), points.end(), pos1) && binary_search(points.begin(), points.end(), pos2))
					res = max((double)res, pow(pos1.first - pos2.first, 2.0) + pow(pos1.second - pos2.second, 2.0));
				
			}
		}
		cout << res << endl;
	}
	//cin.sync(); cin.get();
}

Measured memory_bytes: 968
#include<iostream>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int a[10] = {0};
    for (int i = 0; i < k; ++i) {
        int aa;
        cin >> aa;
        a[aa]++;
    }
    while (1) {
        int tmp = n;
        int flg = 0;
        while (tmp) {
            for (int i = 0; i <= 9; ++i) {
                if (tmp % 10 == i && a[i]) {
                    flg++;
                    break;
                }
            }
            if (flg) {
                break;
            }
            if (tmp / 10 == 0) { //先にflg
                cout << n << endl;
                return 0;
            }
            tmp /= 10;
        }
        n++;
    }
}



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

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

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    string s, t;
    cin >> s >> t;

    for (int i = 0; i < N; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    map<string,int>mymap;
    char str[100];
    for(int i=0; i<n; i++)
        cin>>str,mymap[str]++;
    cout<<"AC "<<"x "<<mymap["AC"]<<endl;
    cout<<"WA "<<"x "<<mymap["WA"]<<endl;
    cout<<"TLE "<<"x "<<mymap["TLE"]<<endl;
    cout<<"RE "<<"x "<<mymap["RE"]<<endl;

    return 0;
}

Measured memory_bytes: 3228
import sys

cin = sys.stdin
#cin = open("in.txt", "r")

MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N+1)
if (N%2==1):
    pos[0]=1
for ai in A:
    if (ai+N)%2==0 or ai>=N or ai<0:
        print(0)
        exit()
    pos[ai]+=1
    if pos[ai]>2:
        print(0)
        exit()
cnt = 1
for i in range(N//2):
    cnt = cnt * 2 % MODULO
print(cnt)

Measured memory_bytes: 13876
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    if(k % 2 == 1) {
        ll x = n / k;
        ll sol = x * x * x;
        cout << sol;
        return 0;
    }
    ll sol = 0;

    for(int i = 1; i <= n; i ++) {
        int c = i / k;
        int j = i - c * k;
        if(j <= 0)
            j = k + j;
        if(j % k == (k / 2) || i % k == 0) {
            ll x = (n - j + k) / k;
            x *= x;
            sol += x;
         //   cout << i << " " << x << endl;
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ll long long int
#define PI 3.141592653589793
using namespace std;

int main() {
    int x,ans;
    int c5=0, c7=0;

    REP(i,3) {
        cin >> x;
        if(x == 5) c5++;
        else if(x == 7) c7++;
    }
    if(c5 == 2 && c7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
def calc(n):
    if n%2==0:
        return int(n/2)
    else:
        return int(3*n+1)

s = int(input())

num = [s]
count = 0
while True:
    
    ans = calc(num[count])
    if ans in num:
        print(count+2)
        break
    num.append(ans)
    count += 1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c;
    d=a/b;
    if(a%b!=0)
        d++;
    if(d<=c)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  ll ans;
  if((B-A)%2==0) ans=(B-A)/2;
  else{
    ans=min(A-1,N-B)+1+(B-A-1)/2;
  }

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


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

    int r,D,x,x2;

    scanf("%d %d %d",&r,&D,&x);

    x2=x;

    for(int i=2000;i<=2009;i++){
       x2=r*x2-D;
       printf("%d\n",x2);
    }

    return 0;

}
    

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

#define int long long

using namespace std;

int f(int a){
    int ans = 0;
    while(a > 0){
        ans+=a%10;
        a/=10;
    }
    return ans;
}

signed main()
{
    vector<int> nums;
    double mn = 1e16;
    for(int i = 1e15-1; i > 0; i-=pow(10,(max(((int)(log10(i))-2), (int)0)))){
        double v = (double)i/(double)f(i);
        if(v-mn < 1e-6){
            nums.push_back(i);
            mn = v;
        }
    }
    reverse(nums.begin(), nums.end());
    int k; cin >> k;
    for(int i = 0; i < k; i++) printf("%lld\n", nums[i]);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long mod=(long)1e9+7;
		int n = sc.nextInt(),m=sc.nextInt();
		char arr[][]=new char[n][m];
		for(int i=0;i<n;i++) arr[i]=sc.next().toCharArray();
		long [][]dp=new long [n][m];
		dp[0][0]=1L;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]=='#')arr[i][j]=0;
				else {
					if(i==0&&j!=0)dp[i][j]=dp[i][j-1];
					else if(i!=0&&j==0)dp[i][j]=dp[i-1][j];
					else if(i==0&&j==0)continue;
					else dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
				}
			}
		}
		pw.println(dp[n-1][m-1]);
		pw.close();		
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}


Measured memory_bytes: 42608
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<(b);i++)
using namespace std;

	bool flag=false;
	string s,ans;
	int k;
	
string solve(void){
FOR(i,0,k){
		if(!flag&&s[i]=='C'){
			flag=true;
		}
		if(flag&&s[i]=='F'){
			return "Yes";
		}
	}	
	return "No";
}
int main(){
	cin>>s;
	k=s.size();
	ans=solve();
	cout<<ans<<endl;
}

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

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

    vector<pair<int, int>> a(n);
    rep (i, n)
        cin >> a[i].first >> a[i].second;

    rep (i, n - 2)
        if (a[i].first == a[i].second && a[i + 1].first == a[i + 1].second && a[i + 2].first == a[i + 2].second)
        {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0,sum=0,n,p=1,i,j,a,b,q,k,l,m;
	scanf("%d %d",&n,&m);
	char s[100][100],s1[100][100];
	for(i=0;i<n;i++)
	scanf(" %s",s[i]);
	for(i=0;i<m;i++)
	scanf(" %s",s1[i]);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(s[i][j]==s1[0][0])
			{
				
				if(n-i>=m && n-j>=m)
				{
					int f=0,c=0;
					//printf("%d %d\n",i,j);
					p=i,q=j;
					for(k=0,p=i;k<m;k++,p++)
					{
						
					
						for(l=0,q=j;l<m;l++,q++)
						{
							//printf("%d %d %d %d %d\n",c,p,q,k,l);
							if(s[p][q]!=s1[k][l])
							{
								f=1;
			
								break;
							}
							//q++;
							//c++;
						}
						//p++;
					}
					if(f==0)
					{
						printf("Yes");
						return 0;
					}
				}
			}
		}
	}
	printf("No");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, a[100], i, j, temp;
    int Alice=0, Bob=0;

    scanf("%d", &n);

    for(i=0; i<n; i++)
        scanf("%d", &a[i]);
    

    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            if(a[i] < a[j]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }

    for(i=0; i<n; i++){
        if(i%2 == 0)
            Alice += a[i];
        else
            Bob += a[i];
    }

    printf("%d\n", Alice-Bob);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,x;
int main(){
  cin>>N>>x;
  int res[2*N];
  if(x==1||x==2*N-1) prin("No");
  else{
    prin("Yes");
    if(x==N){
      rep(i,2*N-1) res[i]=i+1;
    }
    else if(x<N){
      res[N]=x+1;      
      res[N-1]=x;
      res[N-2]=x-1;
      res[N-3]=x+2;
      int j=1;
      rep(i,N-3){
	if(x-1<=j&&j<=x+2) j=x+3;
	res[i]=j;
	j++;
      }
      for(int i=N+1;i<2*N-1;i++){
	if(x-1<=j&&j<=x+2) j=x+3;
	res[i]=j;
	j++;
      }
    }
    else{
      res[N]=x-1;      
      res[N-1]=x;
      res[N-2]=x+1;
      res[N-3]=x-2;
      int j=1;
      rep(i,N-3){
	if(x-2<=j&&j<=x+1) j=x+2;
	res[i]=j;
	j++;
      }
      for(int i=N+1;i<2*N-1;i++){
	if(x-2<=j&&j<=x+1) j=x+2;
	res[i]=j;
	j++;
      }
    }
    rep(i,2*N-1) prin(res[i]);
      
  }
  return 0;
}


Measured memory_bytes: 2304
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// gist: how the answer for the current index depends on the previous index?
//       (in other words, how to build the DP solution?)


#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=998244353;
const int N=3e3+5;

int dp[N][N];           // dp[i][j] -> the answer for sum "j" when we have processed the first "i" indices

void solve()
{
    int n,sum;
    cin>>n>>sum;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    mem(dp,0);
    dp[0][0]=1;
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<=sum;++j)
        {
            dp[i][j]=(2*dp[i-1][j])%M;                 // we have two choices -> to pick this index or not

            if(j-v[i-1]>=0)
                dp[i][j]=(dp[i][j]+dp[i-1][j-v[i-1]])%M;        // we have only one choice -> to pick this index
        }
    }

    cout<<dp[n][sum];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}


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

					using namespace std;
					typedef long long ll;
					ll s;
					int n;
					int main()
					{
						cin >> n;
						for(int i = 1; i <= n; i++)
						for(int j = 1; j <= n; j++)
						for(int q = 1; q <= n; q++)
							s += __gcd(i, __gcd(j, q));
						cout << s;	
					}

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

int main(){
  	int A, B;
  	cin >> A >> B;
  	if(A*B==6){
    	cout << 1 << endl;
    }else if(A*B==3){
    	cout << 2 << endl;
    }else if(A*B==2){
    	cout << 3 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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 = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

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

int main() {
	cin >> n;
	vector<ll> c(n);
	vector<ll> s(n);
	vector<ll> f(n);
	rep(i, n-1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	rep(i, n) {
		ll res = 0;
		if (i == n - 1) {
			cout << 0 << endl; 
			return 0;
		}
		res += s[i] + c[i];
		for (int j = i + 1; j < n-1; j++) {
			if (res % f[j] == 0&&res>=s[j]) {
				res += c[j];
			}
			else if (res % f[j] != 0 && res >= s[j]) {
				res += (f[j] - res % f[j])+c[j];
			}
			else if (res < s[j]) {
				res = s[j];
				res += c[j];
			}
		}
		cout << res << endl;
	}
}

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

const ll INF = 1LL << 60;

ll N, P;
string S;

map<ll, ll> mp;

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

    reverse(S.begin(), S.end());

    if (10 % P == 0) {
        ll ans = 0;
        // 2の倍数
        // 末尾が偶数

        // 5の倍数
        // 末尾が 0 or 5
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += (N - i);
            }
        }
        cout << ans << endl;
        return 0;
    }

    // まず P と 10が素であるとする
    // cout << S << endl;
    // vector<ll> sum(N + 1);
    // sum[0] = 0;

    // rep(i, S.size()) {
    //     sum[i + 1] += sum[i] + (S[i] - '0');        
    //     sum[i + 1] %= P;
    // }

    // rep(i, sum.size()) {
    //     // cout << sum[i] << endl;
    //     mp[sum[i]]++;
    // }
    mp[0] = 1;
    ll ten = 1;
    ll num = 0;
    rep(i, N) {
        ll target = S[i] - '0';
        num += target * ten;
        num %= P;

        mp[num]++;
        ten *= 10;
        ten %= P;
    }

    ll ans = 0;
    for (auto m : mp) {
        // cout << m.first << " " << m.second << endl;
        ll tmp = m.second * (m.second - 1) / 2;
        // cout << tmp << endl;
        ans += tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4164
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  string S;
  cin >> S;
  vector<int> alphabet(26, 0);
  for (int i = 0; i < (int)S.size(); ++i) alphabet[S[i] - 'a']++;
    
  for (int i = 0; i < 26; ++i) {
    if (alphabet[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int X = scan.nextInt();

        int shou = (int)Math.floor(X/100);
        int amari = X%100;

        if(shou*5 < amari) {
            os.println(0);
            return;
        } else {
            os.println(1);
            return;
        }
    }
}

Measured memory_bytes: 23892
while True:
    try:
        f = [list(raw_input()) for _ in xrange(3)]
    except EOFError:
        break
    g = map(lambda x:"".join(x),
            f+zip(*f)+[(f[0][0],f[1][1],f[2][2])]+[(f[2][0],f[1][1],f[0][2])])
    print "b" if "b"*3 in g else "w" if "w"*3 in g else "NA"

Measured memory_bytes: 4220
n, m, k = map(int, input().split())

mod = 1000000007
fac = [1]
for i in range(1, n * m + 1):
    fac.append((fac[-1] * i) % mod)

def pow(x, n):
    ret = 1
    while n > 0:
        if (n & 1) == 1:
            ret = (ret * x) % mod
        x = (x * x) % mod
        n >>= 1
    return ret

def inv(i):
    return pow(fac[i], mod - 2)

def cmb(n, k):
    return (fac[n] * inv(k) * inv(n - k)) % mod

x = sum(d * (m - d) for d in range(m)) % mod
y = sum(d * (n - d) for d in range(n)) % mod

c = cmb(n * m - 2, k - 2)
x = (x * n * n * c) % mod
y = (y * m * m * c) % mod

print((x + y) % mod)

Measured memory_bytes: 11052
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}

  int find(int x) {
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }

  bool unite(int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return false;
    if (d.at(a) > d.at(b)) swap(a, b);
    d.at(a) += d.at(b); d.at(b) = a; 
    return true; 
  }

  bool same(int a, int b) {
    return find(a) == find(b);
  }

  int size(int x) {
    return -d.at(find(x));
  }
};

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> deg(n, 0);
  vector<vector<int>> blocked(n, vector<int>());
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    deg.at(a)++;
    deg.at(b)++;
    uf.unite(a, b);
  }
  rep(i,k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    blocked.at(c).push_back(d);
    blocked.at(d).push_back(c);
  }
  rep(i, n) {
    int v = uf.size(i) - 1 - deg.at(i);
    for(auto &b: blocked.at(i)) {
      if (uf.same(i, b)) v--;
    }
    cout << v;
    if (i == n-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  
  return 0;
}

Measured memory_bytes: 9064
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    long W,H,x,y;
    cin>>W>>H>>x>>y;

    //cout<<double(W)*double(H)/2<<" "<<(x+x==W) && (y+y==H);
    printf("%lf %d\n", double(W)*double(H) / 2, x + x == W&&y + y == H);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k =0,n=0,sum=0,max=-1000;
    if(sc.hasNext())
    k= sc.nextInt();
    n= sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
        arr[i] = sc.nextInt();
    }
    int[] dist = new int[n];
    for(int i=0;i<n-1;i++){
        dist[i] = arr[i+1]-arr[i];
        sum += dist[i];
        if(dist[i]>max){
            max=dist[i];
        }
    }
    dist[n-1]=k-sum;
    sum += dist[n-1];
    if(dist[n-1]>max){
        max=dist[n-1];
    }
    sum=sum-max;

    System.out.println(sum);
  }
}

Measured memory_bytes: 85720
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int n, k, h[1000000], arr[1000000];
int solve( int idx)
{
    if ( idx == n - 1 )
        return 0;
    if ( arr[idx] != -1 )
        return arr[idx];
    int ans = 2e9;
    for(int i = idx + 1; i <= min(idx + k, n - 1); i++)
    {
        ans = min(ans, abs(h[idx] - h[i]) + solve(i) );
    }
    arr[idx] = ans;
    return ans;
}
int main()
{
    Hello
    memset(arr, -1, sizeof arr);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}



Measured memory_bytes: 11136
import java.util.*;

public class Main{
    
    static int[] v,d,c,result,used;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        final int mod = ((int)1e9)+7;
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
        }
        
        //
        int q = Integer.parseInt(sc.next());
        v = new int[q];
        d = new int[q];
        c = new int[q];
        
        for(int i=0; i<q; i++){
            v[i] = Integer.parseInt(sc.next())-1;
            d[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        
        //
        result = new int[n];
        used = new int[n];
        Arrays.fill(used, -1);
        
        for(int t=q-1; t>=0; t--){
            ArrayDeque<Integer> que = new ArrayDeque();
            push(t, v[t], d[t], que);
            
            while(que.size() != 0){
                int i = que.pollFirst();
                if(used[i] != 0){
                    for(int j=0; j<g[i].size(); j++){
                        push(t, g[i].get(j), used[i]-1, que);
                    }
                }
            }
        }
        
        //
        for(int i=0; i<n; i++){
            System.out.println(result[i]);
        }
        
    }
    
    public static void push(int t, int i, int dist, ArrayDeque<Integer> que){
        if(used[i] < dist){
            used[i] = dist;
            if(result[i] == 0){
                result[i] = c[t];
            }
            que.offerLast(i);
        }
    }
}

Measured memory_bytes: 107660
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int k;
       int a,b;
        cin>>k;

        cin>>a>>b;

        int p = b/k  - a/k;

         if(b % k==0 || a%k==0 || p >0){
            cout<<"OK";
         }
         else
         cout<<"NG";
}


Measured memory_bytes: 3636
N = int(input())
T = [[-1] * N for _ in range(N)]
for i in range(N):
    for _ in range(int(input())):
        x, y = map(int, input().split())
        T[i][x - 1] = y

ans = 0
for i in range(1 << N):
    is_kind = [i >> j & 1 for j in range(N)]
    found = True
    for j in range(N):
        if not is_kind[j]:
            continue
        for k in range(N):
            if j == k or T[j][k] == -1 or T[j][k] == is_kind[k]:
                continue
            found = False
        if not found:
            break
    if found:
        ans = max(ans, sum(is_kind))
print(ans)


Measured memory_bytes: 3188
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		long n = sc.nextLong();
		long sum = 0;
		for(long i = 1; i * i < n; i++) {
			long m = n / i - 1;
			if(n / m == n % m) {
				sum += m;
			}
		}
		System.out.println(sum);

	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;


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

    cin >> n;
    string s;
    cin >> s;

    char prev = s[0];

    int cnt =0;
    for(int i=1; i<n; ++i) {
        if(s[i]!=prev)
            cnt++;
        prev=s[i];
    }
    cout << cnt+1 << endl;

    


    return 0;

}



Measured memory_bytes: 512