akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define endl "\n"
#include <map>
#include <numeric>
#include <stack>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    int temp=1000;
    while(temp<=10000)
    {
        if(temp>=n)
        {
            cout << temp-n;
            break;
        }temp+=1000;
    }

    //1 3 1 5 3 6
    //2 6 5 4 2 4//

	return 0;
}


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

dic = {('S','S','o'):'S', ('S','S','x'):'W', ('S','W','o'):'W', ('S','W','x'):'S', \
       ('W','S','o'):'W', ('W','S','x'):'S', ('W','W','o'):'S', ('W','W','x'):'W'}

cnd = [['S','S'], ['S','W'], ['W','S'], ['W','W']]

for h in cnd:
  rlt = h
  l = dic[(h[0],h[1],S[0])]
  for i in range(1,N-1):
    rlt.append(dic[(rlt[i], rlt[i-1], S[i])])
  if l == rlt[-1] and dic[(rlt[-1], rlt[-2], S[-1])] == rlt[0]:
    print(''.join(rlt))
    exit()

print(-1)

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

#define repeat(i,n) for (int i = 0; i < n; ++i)
#define repeat_rev(i,n) for (int i = n-1; 0 <= i; --i)

#define MAX_N 100
#define MAX_v 1000
#define MAX_w 1000
#define MAX_W 10000
int N, W;
typedef struct { int v, w; } item;
item t[MAX_N];
int dp[2][MAX_W+1];

int main() {
    cin >> N >> W;
    repeat (i,N) cin >> t[i].v >> t[i].w;
    int *cur = dp[0]; fill(cur,cur+W,0);
    int *prv = dp[1];
    repeat (i,N) {
        swap(cur,prv);
        repeat (w,W+1) {
            int a = w - t[i].w;
            cur[w] = max(prv[w], (0 <= a ? prv[a] + t[i].v : 0));
        }
    }
    repeat_rev (w,W+1) if (cur[w]) {
        cout << cur[w] << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 1244
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }


    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let p = read_as_vec::<usize>();

    let mut uf = UnionFind::new(n);

    for _ in 0..m{
        let line = read_as_vec::<usize>();
        let (x, y) = (line[0]-1, line[1]-1);
        uf.union(x, y);

    }


    let mut ans = 0;
    for i in 0..n{
        if uf.find(p[i]-1) == uf.find(i){
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
# coding: utf-8
# Your code here!

n=int((input()))
a=list(map(int,input().split()))
mod=10**9+7
b=0
for i in a:
    b+=(pow(i,mod-2,mod))
    
tmp=b%mod

def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x
    
def lcm(x,y):
    G=gcd(x,y)
    return (x)*(y)//G
    
L=a[0]
for i in a:
    L=lcm(L,i)
    


print(L*tmp%mod)

Measured memory_bytes: 4084
# Your code here!
n=gets.to_i

array=gets.split.map(&:to_i)
array=array.sort

if n%2==0
    
    array2=[]
    i=1
    (n/2).times{
        array2<<i
        array2<<i
        i+=2
    }

else
    array2=[0]
    k=2
    jjj=(n-1)/2
    jjj.times{
        array2<<k
        array2<<k
        k+=2
        
        
    }
end






if n%2==0 && array2==array
  aa=2**(n/2)
  puts aa%1000000007

elsif n%2==0
 puts 0
 
elsif n%2==1 && array2==array
 jj=(n-1)/2
 aa=2**jj
 puts aa%1000000007
 
 elsif n%2==1
  puts 0
  
  end






















Measured memory_bytes: 10488
#include<iostream>
#include<vector>
using namespace std;
typedef unsigned long long ull;

const ull B = 1000000007;

vector<int> contain(string a, string b){
    vector<int> v;
    int al = a.length(), bl = b.length();
    if(al > bl) return v;

    ull t = 1;
    for(int i = 0; i < al; i++) t *= B;

    ull ah = 0, bh = 0;
    for(int i = 0; i < al; i++) ah = ah*B + a[i];
    for(int i = 0; i < al; i++) bh = bh*B + b[i];

    for(int i = 0; i + al <= bl; i++){
        if(ah == bh)    v.push_back(i);
        if(i+al < bl)   bh = bh*B - b[i]*t + b[i+al];
    }

    return v;
}

int main(){
    string t, p;
    cin >> t >> p;
    vector<int> v = contain(p, t);
    for(int x : v)  cout << x << endl;
    return 0;
}


Measured memory_bytes: 9348
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string w;
    cin >> w;
    VI hash(256, 0);
    REP(i, w.size()) hash[w[i]]++;
    REP(i, 256) {
        if(hash[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順
ll gcd(ll x, ll y)
{
  if(x<y)
  {
    swap(x,y);
  }
  while(y>0)
  {
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}
int main(){
  int n;cin>>n;
  ll x;cin>>x;
  VL y(n+1,0);
  REP(i,n){
    cin>>y[i];
  }
  y[n]=x;
  sort(y.begin(),y.end());
  ll past=y[1]-y[0];
  for(int i=0;i<n;i++){
    ll now=y[i+1]-y[i];
    past=gcd(past,now);
  }
  cout<<past<<endl;
}

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

public class Main {
  private static int solve(int aMax, int bMax, int cMax, int x) {
    int count = 0;
    for (int a = 0; a <= aMax; a++) {
      for (int b = 0; b <= bMax; b++) {
        int c = (x - 500 * a - 100 * b) / 50;
        if (0 <= c && c <= cMax) {
          count++;
        }
      }
    }
    return count;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int a = reader.nextInt();
    int b = reader.nextInt();
    int c = reader.nextInt();
    int x = reader.nextInt();
    out.println(solve(a, b, c, x));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
k,x=gsmi
puts_yesno(500*k>=x)

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	int n,p[212345];
	int mx[212345];
	mx[0]=1e9;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i+1];
		mx[i+1]=min(mx[i],p[i+1]);
	}

	int res=0;
	for(int i=1;i<=n;i++)
	{
		if(mx[i]>=p[i]) res++;
	}

	cout<<res<<endl;
		



    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int sum = 0;
    rep(i,m){
        int x;
        cin >> x;
        sum += x;
    }
    cout << (sum <= n ? ( n - sum) : -1 ) << endl;


}


Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool number[1000000];

void prime() {
  FOR(i, 1, 1000000) number[i] = true;
  FOR(i, 2, 1000000) {
    if(number[i] == true) {
      for(int j = 2; i*j < 1000000; j++) {
	number[i*j] = false;
      }
    }
  }
}    


int main() {
  int n, count;

  prime();
  while(cin >> n) {
    count = 0;
    for(int i = 2; i <= n; i++) {
      if(number[i] == true)count++;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 2136
def read_key():
    a, _ = map(int, input().split())
    m = 0
    for c in map(int, input().split()):
        m |= 1 << (c - 1)
    return (a, m)


def main():
    INF = float('inf')

    N, M = map(int, input().split())
    keys = [read_key() for _ in range(M)]

    dp = [[INF] * (1 << N) for _ in range(M + 1)]

    dp[0][0] = 0
    for i in range(M):
        a, m = keys[i]
        dpi = dp[i]
        dpi1 = dp[i + 1]
        for j in range(1 << N):
            if dpi[j] == INF:
                continue
            if dpi[j] + a < dpi1[j | m]:
                dpi1[j | m] = dpi[j] + a
            if dpi[j] < dpi1[j]:
                dpi1[j] = dpi[j]

    if dp[M][(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[M][(1 << N) - 1])


main()


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

int main() {
  // 12月30日のM時から次の年になるまでが x時間のとき、xを出力する。
	int M;
	cin >> M;
  
  // M = 21;
  
  	cout << 24 + 24 - M << endl;
}
  

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int n,i,j,k,sum;
	while(scanf("%d",&n)!=EOF){
		sum=0;
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				for(k=0;k<=9;k++){
					if(n-(i+j+k)<=9 && n-(i+j+k)>=0){
						sum++;
					}
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

pair<int, bool> solve(const vector<pair<int, int>>& v) {
    int sh = 0;
    for (auto p : v) {
        int d, h;
        tie(d, h) = p;
        if (d > sh) return make_pair(0, false);
        sh += h;
    }
    return make_pair(sh, true);
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> vp;
    vector<pair<int, int>> vn;
    REP(i, n) {
        string s;
        cin >> s;
        int h = 0;
        int d = 0;
        for (char c : s) {
            if (c == '(') ++h;
            else --h;
            d = min(d, h);
        }
        if (h >= 0) vp.emplace_back(-d, h);
        else vn.emplace_back(h - d, -h);
    }
    sort(ALL(vp));
    sort(ALL(vn));
    int h1, h2;
    bool v1, v2;
    tie(h1, v1) = solve(vp);
    tie(h2, v2) = solve(vn);
    if (h1 != h2 || !v1 || !v2) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 11268
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(x) (int)x.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(a) (1ll<<(a))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
/*并查集
 * int f[];
 * int find(int x){x==f[x]?return f[x]:f[x]=find(f[x]);}
 * int join(int x,int y){if(find(x)!=find(y))f[find(x)]=find(y);}
 * 快速幂*/
int qpow(ll a,ll b,ll m){ll c=1;while(b){if(b&1)c=c*a%m;b>>=1;a=a*a%m;}return c;}
int main(){
	ios::sync_with_stdio(false);
	ll x;
	ll y=100;
	ll ans=0;
	cin>>x;
	while(1){
		if(y>=x)break;
		y*=1.01;
		ans++;
	}
	cout<<ans;
	return 0;
}


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

int ketawa(int a, int b){
  int ret = 0;
  while(a > 0){
    ret += a % 10;
    a /= 10;
  }
  while(b > 0){
    ret += b % 10;
    b /= 10;
  }
  return ret;
}

int main(){
  int n;
  cin >> n;
  int ans = 1e9;
  for(int i = 1; i < n; i++){
    ans = min(ans, ketawa(i, n-i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean[] pr = new boolean[N+1];
        int count = 0;
        for(int i = 2;i < N+1;i++)  pr[i] = true;
        for(int i = 2;i < N+1;i++){
            if(pr[i]){
                count++;
                for(int j = 2*i;j < N+1;j += i) pr[j] = false;
            }
        }
        final int C = count;
        int[] prn = new int[C];
        int id = 0;
        for(int i = 0;i < N+1;i++){
            if(pr[i]){
                int b = i;
                while(b <= N){
                    prn[id] += N/b;
                    b *= i;
                }
                id++;
            }
        }
        int ans = 0;
        for(int i = 0;i < C;i++){
            for(int j = 0;j < C;j++){
                for(int k = j+1;k < C;k++){
                    if(i != j && i != k && prn[i] >= 2 && prn[j] >= 4 && prn[k] >= 4) ans++;
                }
            }
        }
        for(int i = 0;i < C;i++){
            for(int j = 0;j < C;j++){
                if(i != j && prn[i] >= 2 && prn[j] >= 24)   ans++;
            }
        }
        for(int i = 0;i < C;i++){
            for(int j = 0;j < C;j++){
                if(i != j && prn[i] >= 4 && prn[j] >= 14)   ans++;
            }
        }
        if(C > 0 && prn[0] >= 74)    ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>
#include <complex>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define x real()
#define y imag()
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))
//#define M_PI (atan(1)*4)

struct P {
	complex<double> p;
	int id;
	P(){}
	P(double a, double b, int c) {
		p = complex<double>(a,b); id = c;
	}
};

vector<P> pts;
vector<P> cv;

double posarg(double ang) {
	while(ang >= 2*M_PI)
		ang -= 2*M_PI;
	while(ang < 0)
		ang += 2*M_PI;
	return ang;
}

void ConvexHull() {
	P st(1e9,1e9,-1), nx(1e9,1e9,-1);
	rep(i,pts.size()) {
		if(pts[i].p.x < st.p.x)
			st = pts[i];
	}
	assert(st.id >= 0);
	cv.push_back(st);
	double mn = 3*M_PI;
	rep(i,pts.size()) {
		if(pts[i].id == st.id) continue;
		if(posarg( M_PI - arg(pts[i].p - st.p)) < mn) {
			nx = pts[i];
			mn = posarg(M_PI - arg(nx.p - st.p));
		}
	}
	assert(nx.id >= 0);
	cv.push_back(nx);

	while(cv.back().id != cv[0].id) {
		int n = cv.size();
		complex<double> v1, v2;
		v1 = cv[n-1].p - cv[n-2].p;
		mn = 3*M_PI;
		nx = P(1e9,1e9,-1);
		rep(i,pts.size()) {
			if(pts[i].id == cv[n-1].id) continue;
			v2 = pts[i].p - cv[n-1].p;
			if(posarg(arg(v1) - arg(v2)) < mn) {
				mn = posarg(arg(v1) - arg(v2));
				nx = pts[i];
			}
		}
		assert(nx.id >= 0);
		cv.push_back(nx);
	}
	cv.pop_back();
}

int main() {
	int N;
	double ans[110] = {};
	cin >> N;
	rep(i,N) {
		double X, Y;
		cin >> X >> Y;
		pts.push_back(P(X,Y,i));
	}
	ConvexHull();
	/*
	rep(i,cv.size()) {
		cout << cv[i].p.x << " " << cv[i].p.y << endl;
	}
	// */
	rep(i,cv.size()) {
		int sz = cv.size();
		complex<double> v1, v2;
		v1 = cv[i].p - cv[(i-1+sz)%sz].p;
		v2 = cv[(i+1)%sz].p - cv[i].p;
		ans[cv[i].id] = posarg((arg(v1) - arg(v2))) / (2*M_PI);
	}
	double s = 0;
	rep(i,N) {
		//cout << ans[i] << endl;
		printf("%.20f\n", ans[i]);
		s += ans[i];
	}
	//cout << "sum:" << s << endl;
	return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  rep(i, n) { h -= a[i]; }
  if (h <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (ll i=(b)-1; i>=a;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<vector<T> >& vec) {
    REP(i,vec.size()) {
        if(i) os << endl;
        os << vec[i];
    }
    return os;
}
vector<vector<vector<vector<ll>>>> dp;
ll f(int mode, char op, bool ud, bool lr) {
    if (op == 'L' || op == 'R') {
        int res = op == 'R' ? 1 : -1;
        if (lr) res = -res;
        if (mode == 1 || mode == 2) res = -res;
        return res;
    }
    else {
        int res = op == 'U' ? 1 : -1;
        if (ud) res = -res;
        if (mode == 2 || mode == 3) res = -res;
        return res;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    const int n = s.size();
    int K; cin >> K;
    ll ans = 0;
    REP(mode, 4) {
        dp.assign(2, vector<vector<vector<ll>>>(K+1, vector<vector<ll>>(2, vector<ll>(2, -inf))));
        dp[0][0][0][0] = 0;
        REP(i, n) {
            dp[i+1&1].assign(K+1, vector<vector<ll>>(2, vector<ll>(2, -inf)));
            REP(j, K+1) REP(a, 2) REP(b, 2) {
                if (dp[i&1][j][a][b] == -inf) continue;
                // ???????????????
                dp[i+1&1][j][a][b] = max(dp[i+1&1][j][a][b], dp[i&1][j][a][b]+f(mode, s[i], a, b));
                // ??????
                if (j < K) {
                    dp[i+1&1][j+1][!a][b] = max(dp[i+1&1][j+1][!a][b], dp[i&1][j][a][b]+f(mode, s[i], !a, b));
                    dp[i+1&1][j+1][a][!b] = max(dp[i+1&1][j+1][a][!b], dp[i&1][j][a][b]+f(mode, s[i], a, !b));
                }
            }
        }
        REP(j, K+1) REP(a, 2) REP(b, 2) {
            if (dp[n&1][j][a][b] == -inf) continue;
            ans = max(ans, dp[n&1][j][a][b]);
        }
    }
    cout << ans << endl;
}

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

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

int n;
int miny;
int maxy;
int minx;
int maxx;
int xs[114514];
int ys[114514];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    miny = 0;
    maxy = 0;
    minx = 0;
    maxx = 0;
    for (int i=1; i<=n-1; i++) {
      int ni, di;
      scanf("%d%d", &ni, &di);
      xs[i] = xs[ni] + dx[di];
      ys[i] = ys[ni] + dy[di];
      miny = min(miny, ys[i]);
      maxy = max(maxy, ys[i]);
      minx = min(minx, xs[i]);
      maxx = max(maxx, xs[i]);
    }

    printf("%d %d\n", maxx-minx+1, maxy-miny+1);
  }
}

Measured memory_bytes: 3232
N,L=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

res=-1
for i in range(N-1):
	if A[i]+A[i+1]>=L:
		res=i
		break
if res!=-1:
	print("Possible")
	for i in range(res):
		print(i+1)
	for i in range(N-1,res,-1):
		print(i)
else:
	print("Impossible")


Measured memory_bytes: 14264
#include <bits/stdc++.h>
#define lol long long
#define mp(x,y) make_pair(x,y)
using namespace std;

// const int mod=1e9+7;

/*  author: H3XoRuSH  */

signed main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol N;
    cin >> N;
    lol dp[N][3],x[N][3];
    for(lol i=0; i<N; i++) cin >> x[i][0] >> x[i][1] >> x[i][2];
    for(lol i=0; i<N; i++){
        if(i==0){
            dp[i][0]=x[i][0];
            dp[i][1]=x[i][1];
            dp[i][2]=x[i][2];
        }
        else{
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+x[i][0];
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+x[i][1];
            dp[i][2]=max(dp[i-1][0],dp[i-1][1])+x[i][2];
        }
    }
    lol ans=max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m,r,c;
lld arr[300000];
vector<ar<lld,3> >bor;
bool comp(ar<lld,3> a,ar<lld,3> b){
    if (a[0]==b[0]){
        if (a[0]){
                return a[1]>b[1];
        }
        else {
            return a[1]<b[1];
        }
    }
    else {
        if (a[1]==b[1]){
            if (a[1]){
                return a[0]<b[0];
            }
            else {
                return a[0]>b[0];
            }
        }
        else {
            if (a[0]==0) return true;
            if (a[1]==0) return false;
            if (a[0]==r) {
                if (b[1]==0) return true;
                else return false;
            }
            if (b[1]==0||b[0]==r)return true;
            return false;
        }
    }
}
stack<lld> pts;
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
  // cin>>TESTS;
     while(TESTS--)
     {
         cin>>r>>c>>n;
         lld ans=0;
         //bool pos1=false,pos2=false;
         rep(i,0,n-1){
            cin>>x>>y>>a>>b;
            if (((x==0||x==r)||(y==0||y==c))&&((a==0||a==r)||(b==0||b==c))){
                bor.pb({x,y,i});
                bor.pb({a,b,i});
            }
         }
         bool pos=true;
       if (!bor.empty()){  sort(all(bor),comp);
            m=bor.size();
            rep(i,0,m-1){
                if (pts.empty())pts.push(bor[i][2]);
                else {
                    if (pts.top()==bor[i][2])pts.pop();
                    else pts.push(bor[i][2]);
                }
            }
            if (!pts.empty())pos=false;
       }
         (pos)?cout<<"YES":cout<<"NO";
     }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  n -= 2;
  s = s.substr(0, n);
  while (1) {
    string t = s.substr(0, n / 2);
    t += t;
    if (s == t) {
      cout << n << endl;
      return 0;
    }
    n -= 2;
    s = s.substr(0, n);
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	
	if(a == b && b == c) cout << 1 << endl;
	else if(a == b || b == c || c == a) cout << 2 << endl;
	else cout << 3 << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=str(input())
        for i in n:
            if int(i)==7:
                return 'Yes'
        return 'No'
    print(main())

resolve()

Measured memory_bytes: 9180
s = input()

flg = True
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in ['R', 'U', 'D']:
            flg = False
    else:
        if s[i] not in ['L', 'U', 'D']:
            flg = False

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    a,b,c = map(int, input().split())
    print(min(a+b,a+c, b+c))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
n = int(input())
count = 0
flg = False
for i in range(n):
    d1, d2 = (int(d) for d in input().split())
    if d1 == d2:
        count += 1
        if count >= 3:
            flg = True
    else:
        count = 0
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9168
h,n = map(int, input().split())
a = list(map(int, input().split())) 

a = sorted(a, reverse=True)

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
del a[:n]
print(sum_ary(a))

Measured memory_bytes: 26024
#include<stdio.h>
int main(void)
{
	int n,x,m,s,i,d;
	scanf("%d",&n);
	scanf("%d",&x);
	s=1000;
	for(i=1;i<=n;i++){
		scanf("%d",&m);
		x=x-m;
		if(m<s){
			s=m;
	}
	}
	d=x/s+n;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int a[10];
int main()
{
    int i,z,x,c,v,b,p=-1,s=0;
    scanf("%d%c%d%c%d",&z,&x,&c,&v,&b);
    a[0]=z;a[1]=c;a[2]=b;
    for(i=0;i<3;i++)
    {
        s=s+a[i];
        if(a[i]>p)p=a[i];
    }printf("%d\n",s-p);
}


Measured memory_bytes: 128
import sys
import math
input = sys.stdin.readline


def main():
    a, b, x = map(int, input().split())
    h = 2 * x / (a * b)
    if x <= (a **2) * b / 2:
        ans = math.atan(a * (b ** 2) / (2 * x))
        print(math.degrees(ans))
    else:
        ans = math.atan(2 * ((a ** 2) * b - x) / a ** 3)
        print(math.degrees(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    int[] as;
    int s;
    foreach (a; readln.split.to!(int[])) {
        s += a;
        as ~= a;
    }
    sort!"a > b"(as);
    foreach (a; as[0..M]) {
        if (4 * a * M < s) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N), sum(N + 1);
    rep(i, N) {
        cin >> A[i];
        sum[i + 1] = sum[i] + A[i];
    }

    ll ans = 0;
    rep(i, N - 1) {
        ll t = sum[N] - sum[i + 1];
        t %= MOD;
        ans += (t * A[i]) % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;
  cin >> n;
  vector<int> nums(n + 2);
  nums[0] = 0;
  nums[n + 1] = 0;
  r_rep_i(i, 1, n + 1){
    cin >> nums[i];
  }
  vector<int> sa(n + 1);
  rep_i(i, n + 1){
    sa[i] = nums[i+1] - nums[i];
  }

  int sum = 0;
  rep_i(i, n + 1){
    sum += abs(sa[i]);
  }
  int tmp = sum;
  rep_i(i, n){
    if((sa[i] >= 0 && sa[i+1] <= 0) || (sa[i] <= 0 && sa[i+1] >= 0)){
      sum -= (abs(sa[i+1]) + abs(sa[i])) - abs(sa[i+1] + sa[i]);
      // for (int v = 0; v < n+1; v++){
      //   if(v == i){
      //     sum += abs(sa[v] + sa[v + 1]);
      //     v += 1;
      //   }else{
      //     sum += abs(sa[v]);
      //   }
      // }
      cout << sum << endl;
      sum = tmp;
    }else{
      // rep_i(v, n+1){
      //   sum += abs(sa[v]);
      // }
      cout << sum << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> m(h, vector<int>(w, -1));
  int cnt = 0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      char s;
      cin >> s;
      if(s=='#') m[i][j] = 0;
      else cnt++;
    }
  }
  cnt--;
  queue<P> que;
  m[0][0] = 0;
  que.push(make_pair(0,0));
  while(!que.empty()){
    P p = que.front();
    que.pop();
    int x = p.first, y = p.second;
    for(int i=0; i<4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx<0 || nx>=h || ny<0 || ny >=w) continue;
      if(m[nx][ny] != -1) continue;
      m[nx][ny] = m[x][y] + 1;
      que.push(make_pair(nx, ny));
    }
  }
  if(m[h-1][w-1] == -1){
    cout << -1 << endl;
    return 0;
  }
  int ans = cnt - m[h-1][w-1];
  cout << ans << endl;
  return 0;
}


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

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

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

    ll ans[n];
    ll max = 10e9;
    for(int i = 0; i < n; i++){
        ans[i] = max; 
    } 
    ans[0] = 0;
    for(int i = 1; i < n; i++){
        if(i < k){
            for(int j = 0; j < i; j++){
                if(ans[i] > ans[j] + abs(h[i] - h[j])){
                    ans[i] = ans[j] + abs(h[i] - h[j]);
                }
            }
        }else{
            for(int j = 0; j < k; j++){
                if(ans[i] > ans[i - k + j] + abs(h[i] - h[i - k + j])){
                    ans[i] = ans[i - k + j] + abs(h[i] - h[i - k + j]);
                }
            }
        }
    }

    cout << ans[n - 1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
#define fr first
#define sc second
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;

int h, w, n, ans[10][10];
vector< Pii > memo;

int wy, wx;
void plus_n( int y, int x, int nt){
  wy = y;
  wx = ( x + nt ) % w;
  if(!wx) wy++;
  return ;
}
//なんでconstが値変わるの?(困惑)
int dfs( const int mas[][10], const int used, const int y, const int x){
  if( y == h){ //exit
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        ans[i][j] = mas[i][j];
      }
    }
    return 1;
  }
  int ret = 0;
  if( mas[y][x] != 0){
    plus_n( y, x, 1);
    ret += dfs( mas, used, wy, wx);
  }else{
    for(int bit = 0 ; bit < n ; bit++ ){
      if( (used >> bit) & 1 ) continue; // もうやってある

      for(int i = 1 ; i <= memo[bit].fr ; i++ ){ //高さ決定
        if( memo[bit].fr % i != 0 ) continue; // 長方形無理
        int height = i, width = memo[bit].fr / i;
        if( y <= memo[bit].sc.fr && y > memo[bit].sc.fr - height &&
            x <= memo[bit].sc.sc && x > memo[bit].sc.sc - width &&
            y + height - 1 < h && x + width - 1 < w){
          int java[10][10];
          for(int j = 0 ; j < h ; j++ ){
            for(int k = 0 ; k < w ; k++ ){
              java[j][k] = mas[j][k];
            }
          }
          bool ok = true;
          for(int j = 0 ; j < height ; j++ ){
            for(int k = 0 ; k < width ; k++ ){
              if(java[j + y][k + x]) ok = false;
              java[j + y][k + x] = bit + 1;
            }
          }
          if(ok){
            plus_n( y, x, width);
            ret += dfs( java, used|(1<<bit), wy, wx);
          }
        }
      }
    }
  }
  return ret;
}
int main(){
  while(cin >> w >> h >> n , w){
    memo.resize( n);
    for(int i = 0, bf ; i < n ; i++ ){
      cin >> bf;
      cin >> memo[bf - 1].fr;
    }
    for(int i = 0, c ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> c;
        if(c)memo[c - 1].sc = Pi( i, j);
      }
    }
    int mas[10][10] = {{}};
    if(dfs( mas, 0, 0, 0) == 1){
      for(int i = 0 ; i < h ; i++ ){
        for(int j = 0 ; j < w ; j++ ){
          cout << ( j ? " " : "" ) << ans[i][j];
        }
        cout << endl;
      }
    }else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    ll n=str.length(),i,ans=0;
    for(i=0;i<n/2;i++){
        if(str[i]!=str[n-i-1])
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rb(a,b,c) for(int a=b; a<=c; a++)
#define rl(a,b,c) for(int a=b; a>=c; a--)
#define vbe(v) v.begin()
#define ven(v) v.end()
#define all(v) v.begin(), v.end()
#define ll long long
#define vi vector<int>
#define vf vector<float>
#define vd vector<double>
#define vs vector<string>
#define vl vector<long>
#define PB push_back
#define POB pop_back

using namespace std;
const int INF=1e9, MOD=1e9+7;

int main()
{
  ll n, max = 0;
  string s;
  cin >> n;
  vs S;
  map<string, ll> mp;
  rep(i,n)
  {
    cin >> s;
    if(mp[s]==0)
      S.PB(s);
    mp[s] += 1;
    if(max < mp[s])
      max = mp[s];
  }
  sort(all(S));
  rep(i,S.size())
  {
    if(max==mp[S[i]])
      cout << S[i] << endl;
  }
  return 0;
}

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

int main()
{
    std::vector<int> numbers;
    for (int i = 0; i < 10; i++) {
        int value;
        std::cin >> value;
        numbers.push_back(value);
    }
    
    sort(numbers.begin(), numbers.end());

    std::vector<int>::reverse_iterator it = numbers.rbegin();
    std::cout << *it++ << std::endl;
    std::cout << *it++ << std::endl;
    std::cout << *it << std::endl;

    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
void solve(void)
{
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<W*H/2;
  cout<<" ";
  if(x == W/2 && y == H/2)
  {
    cout<<1<<endl;
  }
  else
  {
    cout<<0<<endl;
  }
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
A = [int(i) for i in input().split()]

fl = True
for a in A:
    if a % 2 == 0:
        if not (a % 3 == 0 or a % 5 == 0):
            fl = False

if fl:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 38384
N,x = map(int,input().split(" "))
a = list(map(int,input().split(" ")))
a.sort()
ans =  0
for i in range(N):
    if a[i] > x:
        break
    x -= a[i]
    ans += 1

if N == ans and x >  0:
    ans -= 1

print(ans)


Measured memory_bytes: 38384
s = gets.chomp

ans_a = ans_b = 0

s.length.times do |i|
  c = s[i].to_i

  if i.even?
    ans_a += 1 if c == 0
    ans_b += 1 if c == 1
  else
    ans_a += 1 if c == 1
    ans_b += 1 if c == 0
  end
end

puts ans_a <= ans_b ? ans_a : ans_b


Measured memory_bytes: 1916
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9 + 7;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
var fac=[1,1];
function fSet(n){for(var i=2;i<=n;)fac[i]=abmod(fac[i-1],i++);}
function modinv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function nCrmod(n,r){return abmod(fac[n],modinv(abmod(fac[r],fac[n-r])));}

console.log(main());
function main(){
  var n = o.a();
  var a = o.a();
  var b = o.a();
  var c = o.a();
  fSet(n*2);
  var ab = a+b;
  var abinv = modinv(ab);
  var ainv = abmod(a,modinv(ab));
  var binv = abmod(b,modinv(ab));
  var k = 100 * modinv(100-c) % mod;
  var apow = Array(n+1);
  var bpow = Array(n+1);
  apow[0] = 1;
  bpow[0] = 1;
  for(var i = 1; i <= n; i++){
    apow[i] = abmod(apow[i-1],ainv);
    bpow[i] = abmod(bpow[i-1],binv);
  }
  var ans = 0;
  for(var i = 0; i < n; i++){
    var x = abmod(apow[n-1],bpow[i],nCrmod(n+i-1,i),ainv,n+i);
    var y = abmod(bpow[n-1],apow[i],nCrmod(n+i-1,i),binv,n+i);
    ans += x;
    ans += y;
  }
  return abmod(ans%mod,k);
}

Measured memory_bytes: 33096
from scipy.sparse import *;N=int(input());Z=[[i]+list(map(int,input().split())) for i in range(N)];P=set()
for j in [1,2]:
 Z.sort(key=lambda a:a[j])
 for i in range(1,N):
  a,b,c=Z[i-1]
  d,e,f=Z[i]
  P.add((min(abs(e-b),abs(f-c)),a,d))
d,i,j=zip(*P);print(int(csgraph.minimum_spanning_tree(csr_matrix((d,(i,j)),(N,N))).sum()))

Measured memory_bytes: 81556
#include <stdio.h>
int main(void){
    int a, b;
    char op;
    
    while(1) {
        scanf("%d %c %d", &a, &op, &b);
    
    
        if (op == '+') {
            printf("%d\n", a+b);
        } else if (op == '-') {
            printf("%d\n", a-b);
        } else if (op == '*'){
            printf("%d\n", a*b);
        } else if ( op == '/' ){
            printf("%d\n", a/b);
        } else {
            break;
        }

    }
   
    return 0;
    
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        String mask = "111";
        int count = 0;
        for (int i=0; i<input.length(); i++) {
            char c = input.charAt(i);
            if (c=='1') count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716