akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

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

  ll ret = 0;

  for(int i = n-1; i >= 0; i--){

    ll cur = a[i] + ret;
    if(cur % b[i] != 0){
      ret += b[i] - cur % b[i];
    }
    

  }

  cout << ret << endl;




  return 0;
}


Measured memory_bytes: 1792
import sys
_ = input()
PY = sorted([list(map(int, line.strip().split(' ')))+[i] for i,line in enumerate(sys.stdin)])
now_p = None
now_id = 0
for i in range(len(PY)):
  p,y,_ = PY[i]
  if now_p != p:
    now_p = p
    now_id = 1
  else:
    now_id += 1
  PY[i][1] = now_id
for p,id,i in sorted(PY, key=lambda x: x[2]):
  print('{:0>6}{:0>6}'.format(p,id))


Measured memory_bytes: 25540
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>


//Hang in there!

using namespace std;


int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>data(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> data[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << data[i][j];
		}
		cout << endl;
		for (int j = 0; j < W; j++) {
			cout << data[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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



int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    const int inf=100000000;
    int n,m;
    cin>>n>>m;
    int a[1000],b[1000],c[1000],dist[100][100];
    REP(i,m)
    {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--; b[i]--;
    }
    REP(i,n)
    {
        REP(j,n)
        {
            if(i==j) dist[i][j]=0;
            else dist[i][j]=inf;
        }
    }
    REP(i,m)
    {
        dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
    }

    REP(k,n)
    {
        REP(i,n)
        {
            REP(j,n)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    int ans=m;
    REP(i,m)
    {
        bool shortest= false;
        REP(j,n) {if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;}
        if(shortest)
        {
            ans=ans-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define mod LLONG_MAX
#define ll long long
#define pi 3.141592653589
using namespace std;

struct ca
{
  char a;
   int si,ei;
};



int binarySearch(vector<int> arr, int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
         
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
       
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    
    return -1; 
} 

int prime[1000001]={};

void pr()
{
  prime[1]=0;

 for(int i=2;i*i<1000001;i++)
  if(prime[i]==0)
  for(int j=i*i;j<1000001;j+=i)
  prime[j]=1;

}


ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
  
    x = x % p;  
  
    while (y > 0) 
    { 
         
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 


ll fac[1000001]={};

void facto(ll p)
{
   fac[0] = 1; 
    for (ll i=1 ; i<=1000000; i++) 
        fac[i] = fac[i-1]*i%p; 
}
  
 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
  
   if (r==0) 
      return 1;  
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 



/*
struct cmp
 {

     bool operator() (const ca &a , const ca &b) const
  {
      if(a.val>b.val)
       return true;

      return false;
  }
 };*/


int main()
{

  //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

   //pr();
   //facto(mod);
  int t;
  //cin>>t;
  t=1;
  int id=1;

  

  while(t--)
{
    int n;
      string s;
      cin>>n>>s;

   if(s.length()<=n)
   {
     cout<<s;
      continue;
    }

    s=s.substr(0,n)+"...";

    cout<<s;
}
     



    
      
  


return 0;
}






Measured memory_bytes: 3636
n, m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
tmp = []
m.times { tmp << gets.split.map(&:to_i) }
tmp << [100000, 0]
tmp.sort! { |a, b| b[1] <=> a[1] }
# p tmp

changables = []
tmp.each do |count, num|
  count.times { changables << num }
  break if changables.size >= n
end
# p changables

(0...n).each do |i|
  changable = changables.shift
  if cards[i] <= changable
    cards[i] = changable
  else
    break
  end
end
# p cards

puts cards.inject(:+)


Measured memory_bytes: 20856
#include <bits/stdc++.h>
#define LL long long
#define INF 1e18
#define MAXN 200005
using namespace std;

int n;
LL a[MAXN], ans=INF;

int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++)	scanf("%lld", &a[i]), a[i]+=a[i-1];
	int l=1, r=3;
	LL maxn, minn;
	for(int i=2; i<=n-2; i++)
	{
		while(a[l]<a[i]-a[l] && l<i-1) l++;
		while(a[r]-a[i]<a[n]-a[r] && r<n) r++;
		if(a[l-1]>a[i]-a[l]) l--;
		if(a[r-1]-a[i]>a[n]-a[r]) r--;
		maxn=max(max(a[l], a[i]-a[l]), max(a[r]-a[i], a[n]-a[r]));
		minn=min(min(a[l], a[i]-a[l]), min(a[r]-a[i], a[n]-a[r]));
		ans=min(ans, maxn-minn);
		//printf("%d %d %d %lld %lld!!\n", l, i, r, minn, maxn);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (numberOfSummerHolidays, numberOfHomeWorks) = readLine()!!.split(" ").map{ it.toInt() }
    val homeworkCosts = readLine()!!.split(" ").map { it.toInt() }
    val sumOfHomeworkCost = homeworkCosts.sum()

    if (numberOfSummerHolidays >= sumOfHomeworkCost) {
        println(numberOfSummerHolidays - sumOfHomeworkCost)
    } else {
        println(-1)
    }
}

Measured memory_bytes: 39372
# Node
class Node
  attr_accessor :id, :edges, :cost, :done

  def initialize(id, edges = [], cost = nil, done = false)
    @id, @edges, @cost, @done = id, edges, cost, done
  end
end

# Edge
class Edge
  attr_accessor :to, :cost

  def initialize(to, cost)
    @to, @cost = to, cost
  end
end

# Dijkstra
class Dijkstra
  attr_accessor :nodes

  def initialize(data)
    @nodes = {}
    data.each do |id, edges|
      edges.map! { |edge| Edge.new(*edge) }
      @nodes[id] = Node.new(id, edges)
    end
  end

  def start(start_id)
    @nodes.each do |id, node|
      node.done = false
      node.cost = node.id == start_id ? 0 : -1
    end

    loop do
      done_node = nil
      @nodes.each do |id, node|
        next if node.done || node.cost < 0
        done_node = node if done_node.nil? || node.cost < done_node.cost
      end
      break if done_node.nil?
      done_node.done = true
      done_node.edges.each do |edge|
        node = @nodes[edge.to]
        cost = done_node.cost + edge.cost
        node.cost = cost if node.cost < 0 || cost < node.cost
      end
    end
  end
end

n = gets.chop.to_i

data = {}

n.times do
  u, k, *edges = gets.split.map(&:to_i)
  data[u] = edges.each_slice(2).to_a
end

d = Dijkstra.new data
d.start(0)
d.nodes.each do |id, node|
  puts "#{id} #{node.cost}"
end

Measured memory_bytes: 6140
def LI():
  return [int(s) for s in input().split()]

L,R = LI()

if R - L > 2019:
  R = L + 2019
  
min_mod = 2020

for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j) % 2019 < min_mod:
      min_mod = (i*j) % 2019
      
print(min_mod)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 998244353
#define pb push_back
#define ss second
#define ff first
#define inf 1000000000000000
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x ;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
												//nestedcode
 
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }

}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,i,f = 0;
    double ans,x,y,d;
    cin>>n>>d;
    for(i=0;i<n;i++){
    	cin>>x>>y;
    	ans = sqrt(x*x + y*y);
    	if(ans <= d){
    		f++;
		}
	}
	cout<<f<<endl;
}
   
  

	  


Measured memory_bytes: 3824
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def abc():
    from math import ceil
    a, b, c, d = map(int, input().split())

    cnt_all = b - a + 1

    l = ceil(a / c)
    r = b // c
    cnt_c = r - l + 1

    l = ceil(a / d)
    r = b // d
    cnt_d = r - l + 1

    cd = lcm(c, d)
    l = ceil(a / cd)
    r = b // cd
    cnt_cd = r - l + 1

    ans = cnt_all - (cnt_c + cnt_d - cnt_cd)
    if ans < 0:
        ans = 0
    print(ans)


abc()


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int l = in.nextInt();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = in.next();
		}
		Arrays.sort(s);
		for (int i=0; i<n; i++) {
			out.print(s[i]);
		}
		out.println();
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

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

using ll = long long;
using P = pair<int, int>;

const ll INF=1e9;
const ll MOD=1e9+7;

int main(int, char**)
{
    int n;
    cin >> n;

    vector < vector<int> > cost(n, vector<int>(n));
    rep(i,n) rep(j,n) {
        cost[i][j] = min(min(i, j), min(n-i-1, n-j-1));
    }
    vector < vector<int> > existp(n, vector<int>(n, 1));

    ll ans = 0;
    rep(_,n*n) {
        int ps;
        cin >> ps; ps--;
        int sx = ps / n;
        int sy = ps % n;

        ans += cost[sx][sy];
        existp[sx][sy] = 0;

        int dx[4] = { 0, 1, 0, -1 };
        int dy[4] = { 1, 0, -1, 0 };
        
        queue<P> q;
        q.push({sx, sy});
        while (!q.empty()) {
            int x, y;
            tie(x,y) = q.front();
            q.pop();

            int nc = cost[x][y] + existp[x][y];
            rep(i,4) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx < 0 || ny < 0 || nx >= n || ny >= n || nc >= cost[nx][ny]) continue;
                cost[nx][ny] = nc;
                q.push({nx, ny});
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef complex<double> P;

int main(){
	while(true){
		map<int,int> A;
		for(int i = 0 ; i < 4 ; i++){
			int x;
			if(!(cin >> x))exit(0);
			A[x] = i;
		}
		int h=0,b=0;
		for(int i = 0 ; i < 4 ; i++){
			int x;
			cin >> x;
			if( A.count(x) ){
				if( A[x] == i ) h++;
				else b++;
			}
		}
		cout << h << " " << b << endl;
			

		
	}
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    string T;

    cin >> T;

    rep(i, T.length()) {
        if(T[i] == '?') {
            T[i] = 'D';

        }
    }

    cout << T << endl;
}


Measured memory_bytes: 3724
#include <stdio.h>
#include <string.h>

int n;
char data[5000000];

int conv(char c){
  switch(c){
  case 'A':
    return 1;
    break;
  case 'C':
    return 2;
    break;
  case 'G':
    return 3;
    break;
  case 'T':
    return 4;
    break;
  }
}

int hash(char str[10]){
  int res = 0, size = strlen(str), r = 1, i;
  for(i=size-1;i>=0;i--){
    res += r * conv(str[i]);
    r *= 5;
  }
  return res;
}

void insertElm(int d){
  data[d] = 1;
}

char findElm(int d){
  return data[d];
}

main(){
  char ope[10], str[10];
  int i;
  memset(data, 0, 5000000);
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", ope);
    scanf("%s", str);
    if(!strcmp(ope, "insert")) insertElm(hash(str));
    else printf("%s\n", (findElm(hash(str)) ? "yes" : "no"));
  }
  return 0;
}

Measured memory_bytes: 5268
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut color = vec![0; n];
    color[0] = 1;
    if coloring(0, &graph, &mut color) {
        let b: usize = color.iter().filter(|&&a| a == 1).sum();
        println!("{}", b * (n - b) - m);
    } else {
        println!("{}", n * (n - 1) / 2 - m);
    }
}

fn coloring(v: usize, graph: &Vec<Vec<usize>>, color: &mut Vec<usize>) -> bool {
    for &u in &graph[v] {
        if color[u] == 0 {
            color[u] = if color[v] == 1 { 2 } else { 1 };
            if !coloring(u, graph, color) { return false; };
        } else if color[u] == color[v] { return false; }
    }
    return true;
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
pii edge[125252];

int dat[125252];
int root(int x){
  return dat[x]<0 ? x : dat[x]=root(dat[x]);
}
bool unite(int a, int b){
  a=root(a);b=root(b);
  if(a==b)return false;
  dat[a] += dat[b];
  dat[b] = a;
  return true;
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    edge[i] = pii(a,b);
  }
  ll ans = (ll)n*(n-1)/2;
  fill(dat,dat+n,-1);
  vl aa(m,0ll);
  FORR(i,0,m){
    aa[i] = ans;
    int a = edge[i].first;
    int b = edge[i].second;
    if(root(a) != root(b)){
      ans -= (ll)(-dat[root(a)]) * (-dat[root(b)]);
      unite(a,b);
    }
  }
  REP(i,m)printf("%lld\n",aa[i]);
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<ll> A;
vector<vector<int> > G;
vector<pii> edge;
void input(){
    fast_io();
    cin >> N >> M;
    G.resize(N);
    A = fetch_vec<ll>(N);
    for (int i = 0; i < M; i++)
    {
        int x,y; cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
        edge.emplace_back(x,y);
    }
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  bool same(int x, int y){
      return (find(x)==find(y));
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int solve(){
    int S = N-M;
    if(N<2*(S-1)) {cout << "Impossible" << endl; return 0;}
    UnionFind uf(N);
    for (int i = 0; i < M; i++) uf.unite(edge[i].first, edge[i].second);
    ll ans = 0;
    if(S>1){
        map<int,vector<pii>> c;
        for (int i = 0; i < N; i++)
        {
            c[uf.find(i)].emplace_back(A[i],i);
        }
        for(auto &p:c){
            auto cmp = [](pii a, pii b){return a.first<b.first;};
            sort(p.second.begin(),p.second.end(),cmp);
            ans += p.second[0].first;
            A[p.second[0].second] = LL_INF;
        }
        sort(A.begin(),A.end());
        for (int i = 0; i < S-2; i++)
        {
            ans += A[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 15076
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;


int main(){
  ll n;
  cin >>n;
  ll ans=5;
  ll g=n;
  rep(i,5){
    ll r;
    cin >> r;
    chmin(g,r);
  }
  if(g!=n)ans+=(n+g-1)/g-1;
  cout << ans << endl;
}

Measured memory_bytes: 3640
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

score = [k-q for i in range(n)]
for i in a:
    score[i-1] = score[i-1]+1
    

for i in score:
    if i <= 0:
        print('No')
    else:
        print('Yes')

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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);

// ..... 1/2/3
// x[1][j] = a[j]
// x[i][j] = |x[i-1][j] - x[i-1][j+1]|
//
// x[N][1] = ?
//
//          1 2 3 1 2 3 1
//i=1       1 2 3 1 2 3 1 // 1/2/3 -> 0/1/2
//  2       1 1 2 1 1 2
//  |a1 a2|
//  |a2 a3|
//  |a3 a4|
//  |a.. an|

//  |a1 a2| x1
//  |a2 a3| x 2
//  |a3 a4| x2
//  |a.. an| x1
//
//  1 2 3 4 5 6 7 8
//  12 23 34 45 56 67 78
//  13 24 35 46 57 68
//  1234 2345 3456 4567 5678
//  15 26 37 48
//  1256 2637 3478
//  1357 2468
//  12345678

//  1 2 3 4 5 6 7
//  12 34 45 56 67
//  13 24 35 46 57
//  1234 2345 3456 4567
//  15 26 37
//  1256 2367
//  1357
//

int a[1'000'010];
int newa[1'000'010];
char s[1'000'010];
int n;

// all 2/0 -> 2/0
// if 1 exist -> must 1 0? 2, prove: each 2, if 1 .? 2, if(1 in .) move 1 -> , if(2 in .), do (1 .? 2).? 2, so must 1 0? 2 -> 1
//
// so if 1 exist -> 1/0
//
// only consider of even/odd

int main(){
  cin>>n;
  scanf("%s",s);
  if(n==1){
    cout<<s[0]<<endl;
    return 0;
  }
  rep(i,0,n-1){
    a[i]=abs(s[i+1]-s[i]);
  }
  n--;
  // rep(i,0,n){
  //   cout<<a[i]<<" ";
  // }
  // cout<<endl;
  bool all02 = true;
  rep(i,0,n){
    if(a[i] == 1){
      all02 = false;
      break;
    }
  }
  if(all02){
    rep(i,0,n){
      a[i]/=2;
    }
  }
  while(n != 1){
    // rep(i,0,n){
    //   cout<<a[i]<<" ";
    // }
    // cout<<endl;
    int mi2 = 1;
    while(mi2 <= n){
      mi2<<=1;
    }
    mi2/=2;
    // cout<<"mi2:"<<mi2<<endl;
    int s = 0;
    rep(i,0,mi2){
      s+=a[i];
    }
    newa[0] = s%2;
    // cout<<"n:"<<n<<endl;
    rep(j,1,n+1-mi2){
      s-=a[j-1];
      s+=a[mi2+j-1];
      newa[j] = s%2;
    }
    n-=mi2;
    n+=1;
    rep(i,0,n){
      a[i]=newa[i];
    }
  }
  cout<<(all02?2*a[0]:a[0])<<endl;

  return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
template<typename T> inline T& Min(T &x,const T &y) {return x>y?(x=y):x;}
template<typename T> inline T& Max(T &x,const T &y) {return x<y?(x=y):x;}
const int q=1e9+7;
inline int Plus(int x,int y) {return x+y>=q?(x+y-q):(x+y);}
inline int Sub(int x,int y) {return x<y?(x-y+q):(x-y);}
inline int& Pe(int &x,int y) {return x=Plus(x,y);}
const int maxn=2e5+10;
int n,L[maxn],R[maxn];
struct A {
	int x,v;
	inline bool operator < (const A &d) const {
		return x<d.x;
	}
} a[maxn];
struct range {
	int l,r;
	inline bool operator < (const range &d) const {
		return r!=d.r?(r<d.r):(l<d.l);
	}
} b[maxn];
void disc() {
	static int V[maxn];
	for (int i=1;i<=n;++i) V[i]=a[i].v;
	sort(V+1,V+n+1);
	for (int i=1;i<=n;++i) a[i].v=lower_bound(V+1,V+n+1,a[i].v)-V;
}
namespace bit {
	int n,c[maxn];
	inline void set_n(int _n) {
		n=_n+1;
	}
	inline int lowbit(int x) {
		return x&-x;
	}
	void inc(int x,int d) {
		for (++x;x<=n;x+=lowbit(x)) Pe(c[x],d);
	}
	int sum(int x) {
		int ret(0);
		for (++x;x;x-=lowbit(x)) Pe(ret,c[x]);
		return ret;
	}
	inline int sum(int x,int y) {
		return Sub(sum(y),sum(x-1));
	}
}
int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i].x=read(),a[i].v=read();
	disc();
	sort(a+1,a+n+1);
	for (int i=1,tmp=INT_MIN;i<=n;++i) b[i].r=Max(tmp,a[i].v);
	for (int i=n,tmp=INT_MAX;i>0;--i) b[i].l=Min(tmp,a[i].v);
	sort(b+1,b+n+1);
	bit::set_n(n);
	bit::inc(0,1);
	for (int i=1;i<=n;++i) {
		int tmp=bit::sum(b[i].l-1,b[i].r);
		bit::inc(b[i].r,tmp);
	}
	int ans=bit::sum(n,n);
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    int A,B,C;
    long long X,Y,buf;
    cin >> A >> B >> C >> X >> Y;
    long long min=X*A+Y*B;
    for(int i=0;i<=X+Y;i++){
        if(i>=X&&i>=Y){
            buf=2*C*i;
        }else if(i<X&&i>=Y){
            buf=2*C*i+A*(X-i);
        }else if(i>=X&&i<Y){
            buf=2*C*i+B*(Y-i);
        }else{
            buf=2*C*i+A*(X-i)+B*(Y-i);
        }
        if(buf<min){
            min = buf;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int i,j,n,m;
    cin>>n>>m;
    int Max=m,Min=m;
    for(i=1;i<n;i++){
        cin>>m;
        if(m>Max)
            Max=m;
        if(m<Min)
            Min=m;
    }
    cout<<Max-Min<<endl;
}


Measured memory_bytes: 256
x,y = map(int, input().split())
if abs(x) <= abs(y):
    c = abs(abs(x) - abs(y))
    if x >= 0 and y >= 0:
        print(c)
    elif x < 0 and y < 0:
        print(c+2)
    else:
        print(c+1)
else:
    c = abs(abs(x) - abs(y))
    if y == 0 and x < 0:
        print(c)
    elif y ==0 and x>=0:
        print(c+1)
    elif x >= 0 and y >= 0:
        print(c+2)
    elif x < 0 and y < 0:
        print(c)
    else:
        print(c+1)

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

long long n, a[100000], b[100000], sum = 0;

int main(){
	cin >> n;

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

	for (int i = n - 1; i >= 0; i--){
		if ((a[i] + sum) % b[i] != 0){
			sum += b[i] - ((a[i] + sum) % b[i]);
		}
	}

	cout << sum;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

#define S 6
// right, down, left, up
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int const MOD = 1000000007;

int main() {
    bool board[S][S][4] = {};
    // rep(i,0,S) board[i][S-1][0] = true; // right
    // rep(i,0,S) board[S-1][i][1] = true; // down
    // rep(i,0,S) board[i][0][2]   = true; // left
    // rep(i,0,S) board[0][i][3]   = true; // up

    rep(i,0,9) {
        int l, n;
        if(i % 2 == 0) l = 4;
        else l = 5;
        rep(j,0,l) {
            scanf("%1d", &n);
            if(n == 1) {
                if(i % 2 == 0) {
                    board[i/2][j+1][1] = true;
                    board[i/2+1][j+1][3] = true;
                }
                else {
                    board[i/2+1][j][0] = true;
                    board[i/2+1][j+1][2] = true;
                }
            }
        }
    }

    string d = "RDLU";
    string ret;
    int dir = 0;
    int nx = 0, ny = 1;
    for(int i=0; i<150; i++) {
        // printf("test: board[%d][%d][%d] = %d\n", nx, ny, (dir)%4, board[nx][ny][(dir)%4] ? 1 : 0);
        if(nx == 1 && ny == 0 && dir == 2) break;
        if(nx == 0 && ny == 0 && dir == 3) break;
        int x, y;
        x = nx + dx[dir], y = ny + dy[dir];
        if(board[nx][ny][(dir + 1) % 4] == 0) {
            // printf("case 1: (%d, %d)\n", nx, ny);
            dir = (dir + 1) % 4;
            nx = nx + dx[dir], ny = ny + dy[dir];
        }
        else if(board[nx][ny][dir] == 1) {
            // printf("case 2: (%d, %d)\n", nx, ny);
            ret += d[dir];
            dir = (dir - 1 + 4) % 4;
        }
        else {
            ret += d[dir];
            nx = x, ny = y;
        }
    }
    // printf("endx: %d, endy: %d, dir = %d\n", nx, ny, dir);
    cout << ret << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    long long x,y;
    cin>>x>>y;
    long long ans=0;
    while(x<=y){
    x*=2;
    ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}
/*


*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,a,b;
long long quick_pow(long long a,long long b)
{
	long long ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
long long f(int x)
{
	long long ans1=1,ans2=1;
	for(int i=1;i<=x;i++)
		ans1=ans1*i%mod;
	for(int i=n-x+1;i<=n;i++)
		ans2=ans2*i%mod;
	ans2=ans2*quick_pow(ans1,mod-2)%mod;
	return ans2;
}
int main()
{
	cin>>n>>a>>b;//scanf("%d %d %d",&n,&a,&b);	
	printf("%d\n",((quick_pow(2,n)-1+mod)%mod+mod-f(a)+mod-f(b))%mod);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N,T,A;
    cin >> N >> T >> A;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    
    int ans = 1;
    double tmp = abs(double(T)-double(H[0])*0.006 - A);
    
    rep(i,N){
        if (abs(double(T)-double(H[i])*0.006-A)<tmp) {
            tmp = abs(double(T)-double(H[i])*0.006-A);
            ans = i+1;
        }
        
    }
    cout << ans << endl;
    
    return 0;
}


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

#define N 1000000

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int a,d,n;
	while(cin>>a>>d>>n,a||d||n){
		vector<int> v;
		for(int i=a;i<=1000000;i+=d){
			if(isprime[i]) v.push_back(i);
			if(v.size()==n){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
int main()
{
    fio;
   int N;
    cin >> N;
    vector<ll> L(N);
    loop(i, 0,N)
    cin >> L[i];

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] == L[j] || L[j] == L[k] || L[i] == L[k]) { continue; }

                if (L[i] + L[j] > L[k] && L[k] + L[j] > L[i] &&
                    L[k] + L[i] > L[j])
                    cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
def gcd(a,b):#最大公約数
  return a if b == 0 else gcd(b,a%b)

def prime_factorize(n):#素因数分解
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B = map(int,input().split())
X=gcd(A,B)
P=prime_factorize(X)

answer=len(set(P))+1
print(answer)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int ans = 1;
		if(N == 1) {
			System.out.println(M);
			return;
		}
		for(int i = 2; i <= M / N; i++) {
			if(M % i == 0) ans = i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=55,maxm=21;

int n,m;
ll ans=0;
vector <pair<int,int> > g[maxn];
vector <int> v[maxm];
bool vis[maxn];

bool dfs(int id,int x,int fa,int ed){
	if(ed==x) return true;
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].fst,ind=g[x][i].snd;
		if(to==fa) continue;
		if(dfs(id,to,x,ed)){
			v[id].pb(ind);
		//	cout<<x<<" "<<to<<endl;
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		g[a].pb(mp(b,i));
		g[b].pb(mp(a,i));
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		dfs(i,a,-1,b);
	}
/*	for(int i=0;i<m;i++){
		for(int j=0;j<v[i].size();j++) cout<<v[i][j]<<" ";
		cout<<endl;
	}
*/
	for(int mask=0;mask<(1<<m);mask++){
		for(int i=0;i<maxn;i++) vis[i]=false;
		for(int i=0;i<m;i++) if(mask&(1<<i))
			for(int j=0;j<v[i].size();j++) vis[v[i][j]]=true;
		ll sum=1;
	//	for(int i=0;i<n-1;i++) cout<<vis[i]<<" "; cout<<endl;
		for(int i=0;i<n-1;i++) if(!vis[i]) sum<<=1;
	//	cout<<__builtin_popcount(mask)<<" "<<sum<<endl;
		if(__builtin_popcount(mask)%2==0) ans+=sum;
		else ans-=sum;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		char c=scan.next().charAt(0);
		int b=scan.nextInt();
		if(c=='+') System.out.println(a+b);
		else System.out.println(a-b);
	}

}


Measured memory_bytes: 26868
x = raw_input()
m, f, r = x.split()
m = int(m)
f = int(f)
r = int(r)

while m != -1 or f != -1 or r != -1:
    sum = m + f
    if (m == -1 or f == -1) or sum < 30:
        print "F"
    elif sum >= 80:
        print "A"
    elif 80 > sum and sum >= 65:
        print "B"
    elif 65 > sum and sum >= 50:
        print "C"
    elif 50 > sum and sum >= 30:
        if r < 50:
            print "D"
        else:
            print "C"
            
    x = raw_input()
    m, f, r = x.split()
    m = int(m)
    f = int(f)
    r = int(r)

Measured memory_bytes: 6392
s=input()
t=input()
lens=len(s)
lent=len(t)
ans=1000
for i in range(lens-lent+1):
  cnt=0
  for j in range(lent):
    if t[j]!=s[i+j]:
      cnt+=1
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9052
line = gets.split
if line.size == 1
    line = gets
end
A = gets.split
B = gets.split

ans = 0
B.each.with_index do |b, i|
    count = 0
    A.each do |a|
        if B[i] == a
            count += 1
            i += 1
        end
    end
    ans = [ans, count].max
end
puts ans

Measured memory_bytes: 6836
#include<iostream>
#include<cstdio>

using namespace std;

char s[3],count_a,count_b;

int main() {
	cin >> s;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'A')
			count_a++;
		else
			count_b++;
	}
	if (count_a && count_b)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

int main() {
  int K;
  cin >> K;
  long long sum = 0;
  for(int i = 1; i <= K; i++) {
    for(int j = 1; j <= K; j++) {
      for(int k = 1; k <= K; k++) {
        sum += __gcd(i,__gcd(j,k));
      }
    }
  }
  cout << sum;
}


Measured memory_bytes: 3636
#include <iostream>
#include <queue>

int main() {
    std::queue< long > que;
    int k; std::cin >> k;
    for (int i=1; i<10; ++i) que.push(i);
    for (int i=0; i<k-1; ++i) {
        long a = que.front(); que.pop();
        if (a % 10 != 0) que.push(10 * a + (a % 10) - 1);
        que.push(10 * a + (a % 10));
        if (a % 10 != 9) que.push(10 * a + (a % 10) + 1);
    }
    std::cout << que.front() << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    char str[10];
    cin >> str;
    if (str[2] == str[3] && str[4] == str[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    int a, b;
	cin >> a >> b;
	int res = a;
	if (a > b)res--;
	cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long n,h,w,a,b,ans;
int read(){
	int x=0,f=1;
	char ch;
	do{
		ch=getchar();
		if(ch=='-')
		f=-1;
	}while(ch>'9'||ch<'0');
	do{
		x=x*10+ch-'0';
		ch=getchar();
	}while(ch<='9'&&ch>='0');
	return f*x;
}
int main(){
	n=read();
	h=read();
	w=read();
	ans=0;
	for (int i=0;i<n;i++){
		a=read();
		b=read();
		ans+=min((a/h),(b/w));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Written by newbiechd
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

const int BUF = 100003;
inline char getChar() {
  static char buf[BUF], *bufS, *bufT;
  if (bufS == bufT) {
    bufT = (bufS = buf) + fread(buf, 1, BUF, stdin);
    if (bufS == bufT)
      return EOF;
  }
  return *bufS++;
}
inline int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getChar())) {}
  do f = f * 10 + (ch ^ 48);
  while (isdigit(ch = getChar()));
  return f;
}

const int maxN = 403, mod = 998244353;
int a[maxN], b[maxN], dp[maxN][maxN][maxN], inv[maxN];

int main() {
  int n = read(), i, j, k, d, temp, A, B, ans = 0;
  for (i = 1; i <= n; ++i)
    a[i] = read(), b[i] = read();
  inv[1] = 1;
  for (i = 2; i < maxN; ++i)
    inv[i] = -1ll * (mod / i) * inv[mod % i] % mod;
  
  dp[0][0][0] = -1, A = 0, B = 0;
  for (i = 1; i <= n; ++i) {
    temp = 1;
    for (j = 0; j <= A; ++j)
      memcpy(dp[i][j], dp[i - 1][j], sizeof(int) * (B + 1));
    A += a[i], B += b[i] - 1;
    for (d = 0; d < b[i]; ++d, temp = 1ll * temp * a[i] % mod * inv[d] % mod)
      for (j = a[i]; j <= A; ++j)
        for (k = d; k <= B; ++k)
          dp[i][j][k] = (-1ll * dp[i - 1][j - a[i]][k - d] * temp
                         + dp[i][j][k]) % mod;
  }
  
  for (j = 1; j <= A; ++j) {
    temp = 1ll * A * inv[j] % mod;
    for (k = 0; k <= B; ++k, temp = 1ll * temp * k % mod * inv[j] % mod)
      ans = (1ll * dp[n][j][k] * temp + ans) % mod;
  }
  printf("%d\n", (ans + mod) % mod);
  return 0;
}


Measured memory_bytes: 252544
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 200005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;

int main() {
#ifdef ONLINE_JUDGE
#else
    //FREO;
#endif // ONLINE_JUDGE
//FREI;
    ll a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f) {
        a=a*100;
        b=b*100;
        double dl=0.0;
        ll ans=0,res=0;
        for(ll i=0; i<=30; i++) {
            if(a*i>f)break;
            for(ll j=0; j<=30; j++) {
                if(a*i+b*j>f)break;
                for(ll m=0; m<=3000; m++) {
                    if(a*i+b*j+c*m>f)break;
                    for(ll n=0; n<=3000; n++) {
                        ll tmp=a*i+b*j+c*m+n*d;
                        if(tmp>f)break;
                        double tt=1.0*(c*m+n*d)/tmp;
                        //cout<<tmp<<endl;
                        if(tmp<=f&&(c*m+n*d)*100.0<=1.0*(a*i+b*j)*e&&(((c*m+n*d)*ans>(res*tmp))||(ans==0&&res==0))) {
                            // cout<<i<<"  "<<j<<"  "<<m<<" "<<n<<endl;
                            dl=tt;
                            ans=tmp;
                            res=c*m+n*d;
                        }
                    }
                }
            }
        }
        cout<<ans<<" "<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
s1 = int(s[:2])
s2 = int(s[2:])

def cm1(i):
    if i > 0 and i < 13:
        return(True)
    else:
        return(False)

if cm1(s1):
    if cm1(s2):
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if cm1(s2):
        ans = "YYMM"
    else:
        ans = "NA"

print(ans)

Measured memory_bytes: 38384
#include <stdlib.h>
#include <iostream>
//#include <iomanip>

using namespace std;

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

    int N;
    cin >> N;

    double ans = 0.0;
    double currNum;

    for (int i = 0; i < N; i++)
    {
        cin >> currNum;
        ans += (1 / currNum);
        //cout << ans << endl;
    }

    //cout << fixed << setprecision(5);
    cout << (1 / ans) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second 
using  namespace std;
using pii = pair<int, int>;
using ll = long long;
const int N = (int)1e5 + 10;
int a[N], b[N];

int main(){
	int mia = 2e5, mib = 2e5, mi = 4e5;
	int n, m, k, x, y, z;
	scanf("%d%d%d",&n,&m,&k);
	for(int i =1; i<=n;i++){
		scanf("%d",&a[i]);
		mia= min(mia, a[i]);
	}
	for(int i=1;i<=m;i++){
		scanf("%d",&b[i]);
		mib = min(mib,b[i]);
	}
	mi = mia+mib;
	for(int i = 1;i <=k;i++){
		scanf("%d%d%d",&x,&y,&z);
		mi = min(mi, a[x] + b[y] - z);
	}
	printf("%d",mi);
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val x, a, b = sc.nextInt()

    if (b - a <= 0) {
      println("delicious")
    } else if (b - a <= x) {
      println("safe")
    } else {
      println("dangerous")
    }
  }
}

Measured memory_bytes: 27340
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  cout << 700 + 100*count(s.begin(),s.end(),'o') << endl;
    return 0;
}

Measured memory_bytes: 256