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

int main(){
    vector<int> A1(4);
    vector<int> A2(4);
    vector<int> A3(4);
    for(int i = 0; i < 3; i++){
        cin >> A1.at(i);
    }
    for(int i = 0; i < 3; i++){
        cin >> A2.at(i);
    }
    for(int i = 0; i < 3; i++){
        cin >> A3.at(i);
    }
    int N;
    cin >> N;
    vector<int> B(N);
    for(int i = 0; i < N; i++){
        cin >> B.at(i);
    }
    int judge1 = 0;
    int judge2 = 0;
    int judge3 = 0;
    bool count = false;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < N; j++){
            if(A1.at(i) == B.at(j)) judge1++;
        }
        for(int k = 0; k < N; k++){
            if(A2.at(i) == B.at(k)) judge2++;
        }
        for(int l = 0; l < N; l++){
            if(A3.at(i) == B.at(l)) judge3++;
        }
        if(judge1 >= 1 && judge2 >=1 && judge3 >= 1) count = true;
        judge1 = 0;
        judge2 = 0;
        judge3 = 0;   
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < N; j++){
            if(A1.at(0) == B.at(j)) judge1++;
            if(A1.at(1) == B.at(j)) judge2++;
            if(A1.at(2) == B.at(j)) judge3++;
        }
        if(judge1 >= 1 && judge2 >=1 && judge3 >=1){
            count = true;
            
        }
  
    }
    judge1 = judge2 = judge3 = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < N; j++){
            if(A2.at(0) == B.at(j)) judge1++;
            if(A2.at(1) == B.at(j)) judge2++;
            if(A2.at(2) == B.at(j)) judge3++;
        }
        if(judge1 >= 1 && judge2 >=1 && judge3 >=1){
            count = true;

        }    
    }
    judge1 = judge2 = judge3 = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < N; j++){
            if(A3.at(0) == B.at(j)) judge1++;
            if(A3.at(1) == B.at(j)) judge2++;
            if(A3.at(2) == B.at(j)) judge3++;
        }
        if(judge1 >= 1 && judge2 >=1 && judge3 >=1){
            count = true;
        }    
    }
    judge1 = judge2 = judge3 = 0;


    for(int j = 0; j < N; j++){
        if(A1.at(0) == B.at(j)) judge1++;
    }
    for(int j = 0; j < N; j++){
        if(A2.at(1) == B.at(j)) judge2++;
    }
    for(int j = 0; j < N; j++){
        if(A3.at(2) == B.at(j)) judge3++;
    }
    if(judge1 >= 1 && judge2 >=1 && judge3 >=1){
        count = true;
    }
    judge1 = judge2 = judge3 = 0;

    for(int j = 0; j < N; j++){
        if(A1.at(2) == B.at(j)) judge1++;
    }
    for(int j = 0; j < N; j++){
        if(A2.at(1) == B.at(j)) judge2++;
    }
    for(int j = 0; j < N; j++){
        if(A3.at(0) == B.at(j)) judge3++;
    }
    if(judge1 >= 1 && judge2 >=1 && judge3 >=1){
        count = true;
            
    }
    judge1 = judge2 = judge3 = 0;

    if(count) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main(){
	int A, B, C; cin >> A >> B >> C;
	
	int ans = A*10 + B + C;
	if(ans < A + B*10 + C) ans = A + B*10 + C;
	if(ans < A + B + C*10) ans = A + B + C*10;
	
	cout << ans;
	return 0;
}

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

signed main(){
    int a,b,c;
    std::cin >> a >> b >> c;
    if (std::min(a,b) > c || std::max(a,b) < c)
        std::cout << "No\n";
    else
        std::cout << "Yes\n";
    return 0;
}

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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; std::cin >> n;
    std::vector<int> colors(8);
    int higher = 0;
    while (n--) {
        int a; std::cin >> a;
        a = a / 400;
        if (a >= 8) {
            higher++;
        } else {
            colors[a] = 1;
        }
    }
    int count = 0;
    for (auto c : colors) count += c;
    int min = std::max(1, count);
    int max = count + higher;
    std::cout << min << " " << max << std::endl;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 085
//C - Otoshidama
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    int b10=-1;
    int b05=-1;
    int b01=-1;
    FOR(i,0,n){
        FOR(j,0,n-i){
            if ((i*10000+j*5000+(n-i-j)*1000) == y){
                b10 = i;
                b05 = j;
                b01 = n-i-j;
                break;
            }
        }
    }
    cout << b10 << " " << b05 << " " << b01 << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
int X,Y,Z, ch=0,ans=0;
scanf("%d%d%d", &X, &Y, &Z);
ch=Y+Z*2;
for(int i=ch;i<=X;i+=(Y+Z)){
    ans++;
}
printf("%d\n",ans);
return 0;
}

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

int main(void){
    int n,x;
    cin >> n >> x;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin >> d[i];

    int dist = 0;
    int bound = 1;
    for(;bound<=n;bound++){
        dist += d[bound-1];
        if(dist>x) break;
    }
    cout << bound << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e9 + 5;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<string, int> word_count;
    string word;
    int n;
    cin >> n;
    while (n--)
    {
        cin >> word;
        ++word_count[word];
    }
    map<string, int>::iterator iter;
    int maxa = -INF;
    for (iter = word_count.begin(); iter != word_count.end(); iter++)
    {
        maxa = max(maxa, iter->second);
    }
    vector<string> a;
    for (iter = word_count.begin(); iter != word_count.end(); iter++)
    {
        if (iter->second == maxa)
        {
            a.push_back(iter->first);
        }
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << '\n';
}


Measured memory_bytes: 25584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[200005];
int b[200005];
int c[200005];
int main()
{
	int m,n;
	while(~scanf("%d%d",&n,&m))
	{
		memset(c,0,sizeof(c));
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i=0;i<m;++i)
		{
			scanf("%d%d",&a[i],&b[i]);
			if(a[i] == 1)
				c[b[i]]++;
			if(a[i] == n)
				c[b[i]]++;
			if(b[i] == 1)
				c[a[i]]++;
			if(b[i] == n)
				c[a[i]]++;
		}
		int flag = 0;
		for(int i=0;i<n;++i)
		{
			if(c[i] >= 2)
			{
				flag = 1;
				break;
			}
		}
		if(flag)
			printf("POSSIBLE\n");
		else
			printf("IMPOSSIBLE\n");
	}
}

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

using namespace std;

using ll = long long;

int main(){
  ll n;
  vector <ll> a;
  cin >> n;
  cin.ignore();

  ll tmp;
  ll ma = 1; // 分子

  ll tmp_d; // tmpの逆数
  double sum = 0;

  for (ll i = 0; i < n; i++){
    cin >> tmp;
    //ma *= tmp;
    a.push_back(tmp);
    sum += ((double)1) / tmp;
  }

  double ans = 1 / sum;

  //double sum = 0; // 分母
  //for(ll i = 0; i < n; i++){
  //  sum += ma / ((double)a[i]);
  //}
  //double ans = ma / sum;
  printf("%f\n", ans);
  return 0;
}
  


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

int main()
{
	array<int, 32> a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;

	cout << a[k-1] << endl;

	return 0;
}

Measured memory_bytes: 256
while (n, x = gets.split.map(&:to_i))!=[0,0] do
    c = 0
    for i in 1..n-2 do
        for j in i+1..n-1 do
            for k in j+1..n do
                c+=1 if i + j + k == x
            end
        end
    end
    puts c
end


Measured memory_bytes: 6848
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections
sys.setrecursionlimit(10000)

INF = float("inf")

V,E = map(int,sys.stdin.readline().split())
stw = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param

# n x n adjacency matrix
#G = [[-1,2,3],[2,-1,3],[1,2,-1]]
# G = [{} for _ in range(V)]
# for s,t,w in stw:
#     G[s][t] = w
#     G[t][s] = w
wst = [[w,s,t] for s,t,w in stw]
wst.sort()

parents = list(range(V))
def find(x):
  while parents[x] != x:
    x = parents[x]
    parents[x] = parents[parents[x]]
  return x

def union(s,t):
  sp = find(s)
  tp = find(t)
  if sp == tp:
    pass
  elif sp < tp:
    parents[sp] = tp
  else:
    parents[tp] = sp

INF = float("inf")
ret = 0
for w,s,t in wst:
    if find(s) != find(t):
        union(s,t)
        ret += w
print(ret)


Measured memory_bytes: 33096
#include <iostream>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    #define MOD 1e+9 + 9
     
     
    int main(){
        int n;
        char s[5];
        for(int i = 0; i < 4; i++){
            scanf("%c",&s[i]);
        }
        for(int i = 0; i < 4; i++){
            if(s[i] == '+'){
                n++;
            }else{
                n--;
            }
        }
        
        printf("%d",n);
       return 0;
    }

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  cout << (x / 11 * 2 + (x % 11 == 0 ? 0 : (x % 11 > 6 ? 2 : 1))) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int A, B, N;
	
	cin >> N >> A >> B;
	
	int ans = 0;
	FOR(i, 1, N + 1) {
		int ds = 0;
		int tmp = i;
		while (tmp > 0) ds += tmp % 10, tmp /= 10;
		
		if (A <= ds && ds <= B) ans += i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;

int main() {
    double x1, x2, y1, y2;
    double ans;
    cin >> x1 >> x2 >> y1 >> y2;
    ans = sqrt(((x1 - y1)*(x1 - y1) + (x2 - y2)*(x2 - y2)));
    printf("%8lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;

#define int long long
struct Fast { Fast(){ std::cin.tie(0); std::cout.tie(0); ios::sync_with_stdio(false); }} fast;

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

vector<int> a;
map<pair<int, int>, int> mem; // floor, step -> num

int dfs(int f, int n) {

  if (a[f] == -1) return 0;
  if (f > n) return 0;
  if (f == n) return 1;

  int ans = 0;
  for (int i = 1; i <= 2; ++i) {
    auto key = make_pair(f, i);
    int val;
    if (mem.count(key)) {
      val = mem[key];
    } else {
      val = dfs(f + i, n) % MOD;
      mem.insert(make_pair(key, val));
    }
    ans = (ans + val) % MOD;
  }
  return ans;
  
}

signed main(void) {

  int n, m; cin >> n >> m;
  a = vector<int>(n, 0); // 壊れている段を-1とする.
  for (int i = 0; i < m; ++i) {
    int j; cin >> j;
    a[j]= -1;
  }

  cout << dfs(0, n) << endl;
  

    
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
	    int n;
		cin>>n;
		if(n>=400&&n<=599)cout<<8<<endl;
		else if(n>=600&&n<=799)cout<<7<<endl;
		else if(n>=800&&n<=999)cout<<6<<endl;
		else if(n>=1000&&n<=1199)cout<<5<<endl;
		else if(n>=1200&&n<=1399)cout<<4<<endl;
		else if(n>=1400&&n<=1599)cout<<3<<endl;
		else if(n>=1600&&n<=1799)cout<<2<<endl;
		else if(n>=1800&&n<=1999)cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll 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;
int main()
{
    ll N, C;
    cin >> N >> C;
    ll D[C][C];
    ll c[N][N];
    ll mod[N][N];

    rep(i, C) rep(j, C) cin >> D[i][j];
    rep(i, N) rep(j, N) cin >> c[i][j];

    vector<vector<ll>> cnt(3, vector<ll>(C, 0));
    rep(i, N) {
        rep(j, N) {
            //mod[i][j] = ((i + 1) + (j + 1)) % 3;
            cnt[((i + 1) + (j + 1)) % 3][c[i][j] - 1]++;
        }
    }

    ll ans = INF;
    rep(i, C) {
        repd(j, i + 1, C) {
            repd(k, j + 1, C) {
                ll pm[] = {i, j, k};
                do {
                    ll tmp = 0;
                    rep(n1, C) {
                        tmp += D[n1][pm[0]] * cnt[0][n1];
                        tmp += D[n1][pm[1]] * cnt[1][n1];
                        tmp += D[n1][pm[2]] * cnt[2][n1];
                    }
                    ans = min(ans, tmp);
                    /*
                    rep(n1, N) {
                        rep(n2, N) {
                            tmp += D[c[n1][n2] - 1][pm[mod[n1][n2]]];
                        }
                    }
                    ans = min(ans, tmp);
                    */
                    //cout << pm[0] << " " << pm[1] << " " << pm[2] << " " << tmp << endl;
                } while (next_permutation(pm, pm + 3));
            }
        }
    }
    cout << ans << endl;
    return 0; 
}

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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> seat(n,vector<int>(2,0));
    for(vector<int>::size_type i=0;i<seat.size();++i){
        for(vector<int>::size_type j=0;j<seat.front().size();++j){
            cin>>seat.at(i).at(j);
        }
    }
    int filledseat=0;
    for(int i=0;i<n;++i){
        filledseat+=seat.at(i).at(1)-seat.at(i).at(0)+1;
    }
    cout<<filledseat<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[100001][4];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++){
            cin>>a[i][j];
        }
    }
    int ways[100001][3]={0};
    ways[1][1]=a[1][1];
    ways[1][2]=a[1][2];
    ways[1][3]=a[1][3];
    for(int i=2;i<=n;i++){
        ways[i][1]=a[i][1]+max(ways[i-1][2],ways[i-1][3]);
        ways[i][2]=a[i][2]+max(ways[i-1][1],ways[i-1][3]);
        ways[i][3]=a[i][3]+max(ways[i-1][1],ways[i-1][2]);
    }
    int finalans=max(ways[n][1],max(ways[n][2],ways[n][3]));
    cout<<finalans<<"\n";
    return 0;
}
        
    

Measured memory_bytes: 2944
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.b = b
        self.u = u
        self.a=[t,f,r,l,b,u]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d):
        self.a=[self.a[i] for i in self.direction[d]]
        self.t = self.a[0]
        self.f = self.a[1]
        self.r = self.a[2]
        self.l = self.a[3]
        self.b = self.a[4]
        self.u = self.a[5]
t,f,r,l,b,u=map(int,input().split())
dice=Dice(t,f,r,l,b,u)
n=int(input())
s='SSSEWW'
yw='YYY'
for j in range(n):
    t,f=map(int,input().split())
    for d in s:
        if dice.t==t:
            break
        dice.roll(d)
    for t in yw:
        if dice.f==f:
            break
        dice.roll(t)
    print(dice.r)


Measured memory_bytes: 5608
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
struct Point { long double px, py; };
struct Segment { Point p1, p2; };
Point Minus(Point a, Point b) { Point G; G.px = a.px - b.px; G.py = a.py - b.py; return G; }
long double Abs(Point a) { return sqrt(a.px*a.px + a.py*a.py); }
long double norm(Point a) { return a.px*a.px + a.py*a.py; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
    Point a = Minus(p1, p0), b = Minus(p2, p0);
    if (crs(a, b) > 1e-10) return 1;
    if (crs(a, b) < -1e-10) return -1;
    if (dot(a, b) < -1e-10) return 2;
    if (norm(a) < norm(b)) return -2;
    return 0;
}
bool its(Point p1, Point p2, Point p3, Point p4) {
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool its(Segment s1, Segment s2) {
    return its(s1.p1, s1.p2, s2.p1, s2.p2);
}
long double dst(const Segment& a, const Point& b) {
    if (dot(Minus(a.p2, a.p1), Minus(b, a.p1)) < 0.0) return Abs(Minus(b, a.p1));
    if (dot(Minus(a.p1, a.p2), Minus(b, a.p2)) < 0.0) return Abs(Minus(b, a.p2));
    return abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / Abs(Minus(a.p2, a.p1)));
}
int main() {
    Point P1, P2, P3, P4; Segment M1, M2;
    int T; cin >> T;
    for (int i = 0; i < T; i++) {
        cin >> P1.px >> P1.py >> P2.px >> P2.py;
        cin >> P3.px >> P3.py >> P4.px >> P4.py;
        M1.p1 = P1; M1.p2 = P2; M2.p1 = P3; M2.p2 = P4;
        long double res = min(dst(M1, P3), dst(M1, P4));
        res = min(res, min(dst(M2, P1), dst(M2, P2)));
        if (its(M1, M2) == true) { res = 0.0; }
        cout << fixed << setprecision(1919) << res << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int N;
string S;

ll count(char c) {
    ll ret = 0;
    REP (i, N) if (S[i] == c) ret++;
    return ret;
}

ll solve() {
    ll ret = count('R') * count('G') * count('B');

    FOR (gap, 1, N) REP (l, N) {
        ll m = l + gap, r = m + gap;
        if (r >= N) continue;
        if (S[l] == S[m] || S[m] == S[r] || S[r] == S[l]) continue;
        ret--;
    }

    return ret;
}

int main() {
    cin >> N >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

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

vector<pair<ll, ll>> pF;

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


    cout << W * H / 2.0 << " ";
    if(2 * x == W && 2 * y == H){
        cout << "1";
    }else{
        cout << "0";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(readline())
    kyu = 0

    if 400 <= x <= 599:
        kyu = 8
    if 600 <= x <= 799:
        kyu = 7
    if 800 <= x <= 999:
        kyu = 6
    if 1000 <= x <= 1199:
        kyu = 5
    if 1200 <= x <= 1399:
        kyu = 4
    if 1400 <= x <= 1599:
        kyu = 3
    if 1600 <= x <= 1799:
        kyu = 2
    if 1800 <= x <= 1999:
        kyu = 1

    print(kyu)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61768
#include <iostream>
#include <cstring>
#include <math.h>
#include <iomanip>

using namespace std;

const double PI = 3.1415926;

int main(void) {
	int i,n;
	double len,p,angle;
	double pointX[1001],pointY[1001];

	memset(pointX, 0, sizeof(pointX));
	memset(pointY, 0, sizeof(pointY));

	pointX[2] = pointY[2] = 1.0;
	len = 2;
	angle = PI / 4;
	for (i = 3; i < 1001; i++) {
		p = sqrt(len);
		angle += atan(1 / p);
		len += 1;
		p = sqrt(len);
		pointX[i] = p * cos(angle);
		pointY[i] = p * sin(angle);
	}

	while (1) {
		cin >> n;
		if (n == -1) {
			break;
		}
	
		cout << fixed << setprecision(2)<< pointX[n] << endl << fixed<<setprecision(2)<< pointY[n] << endl;
	}
	

	return 0;
}




Measured memory_bytes: 3512
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]
C = [0]*N
tk = 0
ao = 0
for i in range(N):
    C[i] = (sum(AB[i]),i)
for i,j in enumerate(sorted(C)[::-1]):
    tmp = j[1]
    if i % 2 == 0:
        tk+=AB[tmp][0]
    else:
        ao+=AB[tmp][1]
print(tk-ao)

Measured memory_bytes: 36264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
string s;
ll ans,a[500005];
int main(void){
    cin>>s;
    for(int i=0;i<s.size();i++){
		if(s[i]=='<'){
			a[i+1]=a[i]+1;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='>'){
			a[i]=max(a[i],a[i+1]+1);
		}
	}
	for(int i=0;i<s.size()+1;i++)ans+=a[i];
	cout<<ans<<endl;
}


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

using namespace std;

#define ll long long
#define vec vector
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define brep(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair

vec<int> p;

int root(int a)
{
	if (p[a] == a) return a;
	p[a] = root(p[a]);
	return p[a];
}

void unite(int a, int b)
{
	p[root(a)] = root(b);
}

void init(int n)
{
	p.resize(n);
	rep(i, n) p[i] = i;
}

int main(void)
{
	while(1) {
	int n, q;
	cin >> n >> q;
	if (!n && !q) break;
	init(n);
	vec<int> keep(n);
	rep(i, n - 1) {
		int get;
		cin >> get;
		get--;
		p[i + 1] = get;
	}
	keep = p;

	vec<pii> query;
	rep(i, q) {
		char c;
		int v;
		cin >> c >> v;
		v--;
		int get;
		if (c == 'Q') get = 0;
		else get = 1;
		if (!get) query.pb(mp(get, v));
		else {
			if (p[v] == v) continue;
			p[v] = v;
			query.pb(mp(get, v));
		}
	}

	ll sum = 0;
	brep(i, query.size()) {
		if (!query[i].first) sum += (ll)root(query[i].second) + 1;
		else unite(query[i].second, keep[query[i].second]);
	}

	cout << sum << endl;
	}
	return 0;
}

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

int main(){
while(1){
	int m,f,r;
	cin>>m>>f>>r;
	if(m==-1 && f==-1 && r==-1) break;
	string ans;
	if(m==-1 || f==-1) ans="F";
	else if(m+f>=80) ans="A";
	else if(m+f>=65) ans="B";
	else if(m+f>=50) ans="C";
	else if(m+f>=30){
		if(r>=50) ans="C";
		else ans="D";
	}
	else ans="F";
	cout<<ans<<endl;
	}
  return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    int a,b;
    cin >> a >> b;
    cout << ceil((b-1)/(double)(a-1)) << endl;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int n , k;
	cin >> n >> k ;
	vector<int> a(n) , f(n); 
	for(auto &x : a) cin >> x; 
	for(auto &x : f) cin >> x; 
	sort(all(a)) , sort(all(f));
	reverse(all(f));
	int l = -1 , r = a[n-1] * f[0] + 1; 
	while(r - l > 1){
		int m = (l + r) >> 1 ;
		int res = 0;
		rep(i , n){
			if(a[i] * f[i] <= m) continue ;
			int tmp = m / f[i] ;
			res += a[i] - tmp ;
		}
		if(res <= k) r = m;
		else l = m ;
	}
	cout << l + 1 ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

struct Edge{
  int src,dst,cost;
  Edge(int src,int dst,int cost) : src(src), dst(dst), cost(cost) {;}
};

typedef vector<Edge> Edges;
const int inf = 1<<29;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x,int y) {
    x = root(x); y = root(y);
    if(x != y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x,int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

bool operator<(const Edge &e,const Edge &f) {
  return (e.cost != f.cost) ? e.cost>f.cost : e.src<f.src;
}

int kruskal(vector<Edges> &g,int min) {
  priority_queue<Edge> Q;
  int i,j;
  const int n = g.size();
  rep(i,n) {
    rep(j,g[i].size()) {
      if(g[i][j].cost >= min) Q.push(g[i][j]);
    }
  }

  UnionFind uf(n);
  int ee = Q.top().src,maxe = 0;
  while(!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if(uf.findSet(e.src,e.dst)) continue;
    uf.unionSet(e.src,e.dst);
    maxe = max(maxe, e.cost);
  }
  if(uf.size(ee) < n) return -1;
  return maxe - min;
}

int solve(vector<Edges> &g,vector<int> &w) {
  const int n = g.size();
  sort(w.begin(), w.end());
  int mi = w[0],ans = -1,i = 0;
  for(;;) {
    int a = kruskal(g,mi);
    if(a == -1) return ans;
    if(ans == -1) ans = a;
    ans = min(ans, a);
    mi = w[++i];
    if(i == w.size()) return ans;
  }
}


int main() {
  int n,m,i,j,a,b,w;
  while(cin>>n>>m, n|m) {
    vector<Edges> g(n);
    vector<int> weight;
    rep(i,m) {
      cin>>a>>b>>w;
      a--; b--;
      weight.push_back(w);
      g[a].push_back(Edge(a,b,w));
    }

    if(m < (n-1)) cout<<-1<<endl;
    else cout<<solve(g,weight)<<endl;
  }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
char s[200010];
int main(){
int n;
scanf("%d",&n);
scanf("%s",s+1);
int ans=0;
int l=1,r=n;
while(l<r){
    if(s[l]=='W'&&s[r]=='R'){s[l]='W';s[r]='R';ans++;l++,r--;}
    else if(s[l]=='W'&&s[r]=='W'){r--;}
    else if(s[l]=='R'&&s[r]=='R'){l++;}
    else {l++;r--;}
}

//for(l;l<r;l++){
//    if(s[l]=='R')continue;
//    for(r;r>l;r--){
//      if(r=='W')continue;
//      s[l]='R';
//      s[r]='W';
//      ans++;
//      break;
//    }
//}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define MAXN ()
#define INF ()
#define LL long long
#define DD double
#define pii pair<int, int>
using namespace std;
int n, k, a, b, c;
int main()
{
	scanf("%d%d", &n, &k);
	LL ans = 0;
	for (a = 1; a <= n; a++)
	{
		b = c = k - a;
		if (b <= 0)
		{
			b = c = (b + (-b / k * k));
			if (b <= 0)
				b = c = b + k;
		}
		if (b > n || (c + b) % k != 0)
			continue;
		int zs = (n - b) / k + 1;
		ans += ((LL)zs * zs);
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<vector<char>>C(a,vector<char>(b*5,0));
  for(int i=0;i<a;i++){
    for(int j=0;j<b*5;j+=5){
      cin>>C[i][j]>>C[i][j+1]>>C[i][j+2]>>C[i][j+3]>>C[i][j+4];
      if(C[i][j]=='s'){
        if(C[i][j+1]=='n'){
          if(C[i][j+2]=='u'){
            if(C[i][j+3]=='k'){
              if(C[i][j+4]=='e'){
                cout<<char(j/5+65)<<i+1<<endl;
                break;
              }
            }
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class UnionFind {
private:
	vector<int> data;
public:
	int root(int x) { return (x == INF || data[x] < 0) ? x : data[x] = root(data[x]); }
	
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	lint size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	UnionFind UF(N);
	int u, v, len, st0 = INF, st1 = INF;
	queue<pair<int,int>> horyu;
	for (int i = 0; i < N - 1; i++){
		cin >> u >> v >> len;
		if (len % 2 == 0) {
			if (st0 == INF) st0 = u - 1;
			UF.unify(u - 1, v - 1);
		}
		else {
			if (UF.root(u - 1) == UF.root(st0)) {
				if (st1 == INF) st1 = v - 1;
				else UF.unify(st1, v - 1);
			}
			else if (UF.root(v - 1) == UF.root(st0)) {
				if (st1 == INF) st1 = u - 1;
				else UF.unify(st1, u - 1);
			}
			else if (UF.root(u - 1) == UF.root(st1)) {
				if (st0 == INF) st0 = v - 1;
				else UF.unify(st0, v - 1);
			}
			else if (UF.root(v - 1) == UF.root(st1)) {
				if (st0 == INF) st0 = u - 1;
				else UF.unify(st0, u - 1);
			}
			else if (st0 == INF&&st1 == INF) {
				st0 = u - 1, st1 = v - 1;
				horyu.push({ u, v });
			}
			else horyu.push({ u, v });
		}
	}

	while (!horyu.empty()) {
		u = horyu.front().first;
		v = horyu.front().second;
		horyu.pop();

		if (UF.root(u - 1) == UF.root(st0)) {
			if (st1 == INF) st1 = v - 1;
			else UF.unify(st1, v - 1);
		}
		else if (UF.root(v - 1) == UF.root(st0)) {
			if (st1 == INF) st1 = u - 1;
			else UF.unify(st1, u - 1);
		}
		else if (UF.root(u - 1) == UF.root(st1)) {
			if (st0 == INF) st0 = v - 1;
			else UF.unify(st0, v - 1);
		}
		else if (UF.root(v - 1) == UF.root(st1)) {
			if (st0 == INF) st0 = u - 1;
			else UF.unify(st0, u - 1);
		}
		else if (st0 == INF&&st1 == INF) {
			st0 = u - 1, st1 = v - 1;
			horyu.push({ u, v });
		}
		else horyu.push({ u, v });
	}

	for (int i = 0; i < N; i++) {
		if(UF.root(i) == UF.root(st0)) cout << '0' << "\n";
		else cout << '1' << "\n";
	}

	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(){
	int i,count = 0;
	char W[11],T[1001];
	scanf("%s",W);
	while(1){
		scanf("%s",T);
		if(strcmp(T,"END_OF_TEXT")==0){
			break;
		}
		for(i=0;i<strlen(T);i++){ 
			if(T[i] >= 'A' && T[i] <= 'Z')T[i] += 32;
		}
		if(strcmp(T,W) == 0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 548
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

string s;
int p;

int dfs() {
	vi votes;
	while (p < s.size()) {
		if (s[p] == '[') {
			p++;
			votes.push_back(dfs());
		}
		else if (isdigit(s[p])) {
			int num = 0;
			while (s[p] != ']') {
				num = 10 * num + (s[p] - '0');
				p++;
			}
			votes.push_back((num+1)/2);
		}
		else if (s[p] == ']') {
			p++;
			vi v = votes;
			sort(ALL(v));
			int res = 0;
			FOR(i, 0, v.size() / 2) {
				res += v[i];
			}
			return res;
		}
	}
}

int main() {
	int N;
	cin >> N;
	REP(i, N) {
		cin >> s;
		p = 1;
		cout << dfs() << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

// ABC095 at 2018/04/24

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

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        char[] N = sc.nextLine().toCharArray();
        int result = 700;
        for (char c : N) {
            if ("o".equals(String.valueOf(c))) {
                result += 100;
            }
        }
        System.out.println(result);
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int cnt = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }
        for (Integer integer : list) {
            X -= integer;
            cnt++;
        }

        Collections.sort(list);
        int min = list.get(0);
        while(min <= X) {
            X -= min;
            cnt++;
        }
        System.out.println(cnt);

    }

    // ABC095 at 2018/04/29
    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int sum = 0;
        if (C * 2 < A + B) {
            sum += C * 2 * Math.min(X, Y);
            if (Math.max(X, Y) == X) {
                if (C * 2 * (X - Y) <  (X - Y) * A) {
                    sum += C * 2 * (X - Y);
                } else {
                    sum += (X - Y) * A;
                }
            } else {
                if (C * 2 * (Y - X) < (Y - X) * B) {
                    sum += C * 2 * (Y - X);
                } else {
                    sum += (Y - X) * B;
                }
            }
        } else {
            sum += X * A + Y * B;
        }
        System.out.println(sum);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 23764
N, M = map(int, input().split())
a = []
c = []
for _ in range(N):
    a.append(list(map(int, input().split())))
for _ in range(M):
    c.append(list(map(int, input().split())))
for i in range(N):
    min = 10**9
    ans = 0
    for k in range(M):
        tmp = abs(a[i][0]-c[k][0])+abs(a[i][1]-c[k][1])
        if tmp < min:
            min = tmp
            ans = k
    print(ans+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef struct sword
{
	int damage,flag;
	bool operator < (const struct sword & a) const
	{
		return damage>a.damage;
	}
}SWORD,*PSWORD;
SWORD s[200001];
int main()
{
	int n,h,i,j=0,k=0;
	scanf("%d %d",&n,&h);
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[j].damage);
		s[j++].flag=0;
		scanf("%d",&s[j].damage);
		s[j++].flag=1;
	}
	sort(s,s+j);
	i=0;
	while(h>0)
	{
		h-=s[i].damage;
		k++;
		if(s[i].flag==1)
		{
			i++;
		}
		else if(h>0)
		{
			k+=h/s[i].damage;
			k+=h%s[i].damage==0?0:1;
			break;
		}
	}
	printf("%d",k);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<cstdlib>

using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(void){
	int N;
	int l = 0;
	string s;

	cin >> s;
	for(int i =0; i < s.length(); i++){
		l += ctoi(s.at(i));
	}

	if(atoi(s.c_str()) % l == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
	
		boolean flag = true;
		while(flag){
			String[] input=sc.nextLine().split(" ");
			int[] num= new int[input.length];
			for(int i=0;i<input.length;i++){
				num[i]=Integer.parseInt(input[i]);
			}
			if(num[0]==0 && num[1]==0){
				break;
			}
			for(int H=0;H<num[0];H++){
				for(int W=0;W<num[1];W++){
					System.out.print("#");
				}
				System.out.println();				
			}
			System.out.println();				
		}
	}
}

Measured memory_bytes: 34796
#include <stdio.h>
#include <stdlib.h>

int main() {
    int H,W,i,j;
    long *c[2];
    char a;

    scanf("%d %d",&H,&W);

    for(i=0;i<=1;i++) {
        c[i]=(long *)malloc(W*sizeof(long));
    }

    c[0][0]=1;

    for(i=1;i<=H;i++) {
        for(j=1;j<=W;j++) {
            scanf(" %c",&a);
            if(a=='#') c[0][j]=0;
            else if(i==1) c[0][j]=c[0][j-1];
            else c[0][j]=c[1][j]+c[0][j-1];

            if(c[0][j]>1000000007) c[0][j]-=1000000007;
        }

        for(j=1;j<=W;j++) {
            c[1][j]=c[0][j];
        }
        c[0][0]=0;
    }

    printf("%ld\n",c[0][W]);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
char s[1010];
char t[20];
int main(){
	int ans=0;
	scanf("%s",t);
	while(1){
		scanf("%s",s);
		if(!strcmp(s,"END_OF_TEXT"))break;
		for(int i=0;s[i];i++)s[i]|=32;
		if(!strcmp(s,t))ans++;
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int n,k;
	cin>>n>>k;
	int a[n];
	int c=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=k;i<n;i++)
		c+=a[i];
	cout<<c<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

/*
 f(x, y) = C(x + y, y)

 (0, 0) -> (x, y) = f(x - 0, y - 0)
 (a, b) -> (c, d) = f(c - a, d - b) (a <= c && b <= d)

 f(A[i] + A[j], B[i] + B[j]) がほしい
 (-A[j], -B[j]) -> (A[i], B[i]) = f(A[i] + A[j], B[i] + B[j])
 */
ll f[9000], finv[9000];
ll C(int n, int k){
	ll res = f[n];
	res = (res * finv[k]) % MOD;
	res = (res * finv[n - k]) % MOD;
	return res;
}

int ways[4100][4100];
void add(int &x, int y){
	x = (x + y) % MOD;
}

ll mod_pow(ll x, ll e){
	ll v = 1;
	for(;e;e>>=1){
		if(e & 1)v = (v * x) % MOD;
		x = (x * x) % MOD;
	}
	return v;
}

int main(){
	f[0] = 1;
	for(int i=1;i<9000;i++)f[i] = f[i-1] * i % MOD;
	finv[8999] = mod_pow(f[8999], MOD - 2);
	for(int i=8998;i>=0;i--)finv[i] = finv[i + 1] * (i + 1) % MOD;

	int N;
	cin >> N;

	vector<int> A(N), B(N);
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}

	for(int i=0;i<N;i++){
		ways[2000 - A[i]][2000 - B[i]] += 1;
	}
	for(int i=0;i<4100;i++)for(int j=0;j<4100;j++){
		if(i > 0) add(ways[i][j], ways[i-1][j]);
		if(j > 0) add(ways[i][j], ways[i][j-1]);
	}

	ll res = 0;
	for(int i=0;i<N;i++){
		res += ways[2000 + A[i]][2000 + B[i]];
		res += MOD - C(2 * A[i] + 2 * B[i], 2 * A[i]);
		res %= MOD;
	}
	res = (res * mod_pow(2, MOD - 2)) % MOD;
	cout << res << endl;
	return 0;
}


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

int main()
{
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.length() <= K)
    {
        cout << S << endl;
    }
    else
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

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

using namespace std;
typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n, m, l; cin >> n >> m >> l;
    vector<vector<ll>> dp(n, vector<ll>(n, LINF));
    rep(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }

    vector<vector<ll>> dp2(n, vector<ll>(n, LINF));
    rep(i, n) rep(j, n) {
        if (dp[i][j] <= l) dp2[i][j] = 1;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);
    }

    int q; cin >> q;
    rep(i, q) {
        int s, t; cin >> s >> t;
        s--; t--;
        if (dp2[s][t] == LINF) cout << -1 << endl;
        else cout << dp2[s][t]-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
first_args = raw_input().split()
second_args = raw_input().split()

max_row = int(first_args[0])
max_col = int(first_args[1])

fill_row = int(second_args[0])
fill_col = int(second_args[1])

if(fill_row <= max_row and fill_col <= max_col):
  all_cells = max_row * max_col
  filled_cells = (fill_row * max_col) + (fill_col * max_row) - (fill_row * fill_col)

  print all_cells - filled_cells


Measured memory_bytes: 2568
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
char p[110];
int n;
long long K, Res;
void Add(long long l, long long c) {
	Res += (l / 2)*c;
}
int main() {
	vector<int>T;
	int i;
	scanf("%s", p);
	scanf("%lld", &K);
	for (i = 0; p[i]; i++);
	n = i;
	int c = 0;
	for (i = 0; i < n; i++) {
		c++;
		if (i == n-1 || p[i] != p[i + 1]) {
			T.push_back(c);
			c = 0;
		}
	}
	if (p[0] != p[n - 1]) {
		for (auto &t : T) {
			Add(t, K);
		}
	}
	else {
		if (T.size() == 1) {
			long long z = n * K;
			Add(z, 1);
		}
		else {
			int sz = T.size();
			for (i = 0; i < sz; i++) {
				Add(T[i], 1);
				if(i!=0&&i!=sz-1)Add(T[i], K - 1);
			}
			Add(T[0] + T[sz - 1], K - 1);
		}
	}
	printf("%lld\n", Res);
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
map<string,int>m;
int main() {	
	int n;
	cin>>n;
	for(int i=0;i<n;i++) {
		string s;
		cin>>s;
		m[s]++;
	}
	printf("AC x %d\n",m["AC"]);
	printf("WA x %d\n",m["WA"]);
	printf("TLE x %d\n",m["TLE"]);
	printf("RE x %d\n",m["RE"]);
}


Measured memory_bytes: 3256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int par[100500];

void init(int x){
  rep(i,x) par[i]=i;
}

int root(int x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(int x,int y){
  return root(x)==root(y);
}

void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y) return;
  par[x]=y;
}
 
int main(void){
  int N,M,ans=0;
  cin >> N >> M;
  init(N);
  int A[N];
  rep(i,N) cin >> A[i];
  rep(i,N) A[i]--;
  rep(i,M){
    int x,y;
    cin >> x >> y;
    x--,y--;
    unite(A[x],A[y]);
  }
  rep(i,N) if(same(A[i],i)) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
t_arr = list(map(int, input().split()))
total = sum(t_arr)
M = int(input())
ans_arr = []
for _ in range(M):
    p, x = map(int, input().split())
    ans_arr.append(total - t_arr[p-1] + x)
for m in range(M):
    print(ans_arr[m])

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main()
{
    long long i,j,k,a,b,c,d,p,q,r,n,l;

    scanf("%lld %lld",&n,&l);

    long long aa[n];

    for(i=1;i<=n;i++)
    {
        aa[i]=l+i-1;
    }
    a=0;
    for(i=1;i<=n;i++)
    {
        a=a+aa[i];
    }
    if(l+n-1<0)
    {
        printf("%lld\n",a-(l+n-1));
    }
    else if(l>=0)
    {
        printf("%lld\n",a-l);
    }
    else
    {
        printf("%lld\n",a);
    }
}


Measured memory_bytes: 128