akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet
{
public:
    DisjointSet(int size) : fathers_(size, -1) {}

    void Unite(int a, int b);

    bool SameGroup(int a, int b);

private:
    int GetRoot(int node);

    vector<int> fathers_;
};

int DisjointSet::GetRoot(int node)
{
    if (fathers_[node] == -1) {
        return node;
    }
    return fathers_[node] = GetRoot(fathers_[node]);
}

void DisjointSet::Unite(int a, int b)
{
    auto root_a = GetRoot(a);
    auto root_b = GetRoot(b);

    if (root_a != root_b) {
        fathers_[root_b] = root_a;
    }
}

bool DisjointSet::SameGroup(int a, int b)
{
    return GetRoot(a) == GetRoot(b);
}

using Graph = vector<vector<int64_t>>;

int64_t Solve(const Graph &g)
{
    int64_t cost = 0;
    int n = g.size();

    for (int i = 0; i < n; i += 1) {
        for (int j = i + 1; j < n; j += 1) {
            auto direct_edge = true;
            for (int k = 0; k < n; k += 1) {
                if (i == j || i == k || j == k) {
                    continue;
                }
                if (g[i][k] + g[k][j] < g[i][j]) {
                    return -1;
                } else if (g[i][k] + g[k][j] == g[i][j]) {
                    direct_edge = false;
                }
            }
            if (direct_edge) {
                cost += g[i][j];
            }
        }
    }
    return cost;
}

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

    Graph graph(nodes, vector<int64_t>(nodes));
    for (auto &row : graph) {
        for (auto &num : row) {
            cin >> num;
        }
    }

    auto res = Solve(graph);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int a[] = {100,101,102,103,104,105};
int used[100010];
int calc(int x) {
  if (x == 0) return 1;
  else if (x < 0) return 0;
  if (used[x] != -1) return  used[x];
  int res = 0;
  for (int i = 0; i < 6; i++) {
    if (x - a[i] > 0) {
      used[x-a[i]] = calc(x-a[i]);
      res |= used[x-a[i]];
    }
    else res |= calc(x-a[i]);
  }
  return res;
}


int main(){
  int x;
  cin >> x;
  for (int i = 0; i <= x; i++) used[i] = -1;
  used[0] = 1;
  cout << calc(x) << endl;
  return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n, t;
    ll h[100005], tt[100005];
    cin>>n>>t;
    for (int i = 1; i <= n; i++) {
        cin>>h[i];
    }
    tt[1] = 0;
    for (int i = 2; i <= n; i++) {
        tt[i] = tt[i - 1] + h[i - 1];
    }
    ll ans[100005];
    ll T[100005];
    ans[1] = (t / h[1]) + 1;
    int m = 1;
    cout<<ans[1]<<endl;
    for (int i = 2; i <= n; i++) {
        if (h[i] > h[m]) {
            m = i;
        }
        ans[i] = ceil((double)(t - tt[i] - h[i] + 1) / h[m] + 1);
        cout<<max(1LL, ans[i])<<endl;
    }
    return 0;
}


Measured memory_bytes: 4652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;

    rep(b, 1<<3) {
        ll now = s[0] - '0';
        vector<char> op(3);
        rep(i, 3) {
            if(b & 1<<i) {
                now += s[i+1] - '0';
                op[i] = '+';
            }
            else {
                now -= s[i+1] - '0';
                op[i] = '-';
            }
        }
        if(now == 7) {
            cout << s[0];
            rep(i, 3) {
                cout << op[i] << s[i+1];
            }
            cout << "=7" << endl;
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] s = new int[N][2];
		int[][] c = new int[M][2];
		for(int i = 0; i < N; i++) {
			s[i][0] = sc.nextInt();
			s[i][1] = sc.nextInt();
		}
		for(int i = 0; i < M; i++) {
			c[i][0] = sc.nextInt();
			c[i][1] = sc.nextInt();
		}

		for(int i =0; i < N; i++) {
			int min = Math.abs(s[i][0] -c[0][0]) + Math.abs(s[i][1] -c[0][1]);
			int tmp = 0;
			int num = 1;
			for(int j = 0; j < M; j++) {
				tmp = Math.abs(s[i][0] -c[j][0]) + Math.abs(s[i][1] -c[j][1]);
				if(tmp < min) {
					min = tmp;
					num = j + 1;
				}
			}
			System.out.println(num);
		}
		}
}

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

using namespace std;

typedef long long ll;

const int N = 18;

int a[1 << N];
pair<int, int> dp[1 << N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n;
    m = 1 << n;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        dp[i].first = a[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (j & (1 << i)) {
                continue;
            }
            int k = j ^ (1 << i);
            int t[4] = { dp[k].first, dp[k].second, dp[j].first, dp[j].second };
            sort(t, t + 4);
            dp[k].first = t[3];
            dp[k].second = t[2];
        }
    }
    int ans = 0;
    for (int i = 1; i < m; ++i) {
        ans = max(ans, dp[i].first + dp[i].second);
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 100; i <= 999; i++) {
        int first = i / 100;
        int second = (i%100) / 10;
        int third = i % 10;
        bool first_is_ok = (first >= 1 && first <= n);
        bool second_is_ok = (second >= 1 && second <= n);
        bool third_is_ok = (third >= 1 && third <= n);
        if (first_is_ok && second_is_ok && third_is_ok) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	int n,l;
	cin>>n>>l;
	vector<pair<string,int> >v;
	rep(i,n){
		string s;
		cin>>s;
		v.pb(mp(s,1));
	}
	string ans="";
	sort(all(v));
	rep(i,sz(v)){
		ans+=v[i].F;
	}
	cout<<ans;


}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int x = 0;
        boolean approved = true;
        
        for(int i = 0; i < n; i++) {
            x = Integer.parseInt(sc.next());
            if((x%2==0)&&(x%3 != 0)&&(x%5 != 0)) approved = false;
        }
        if(approved){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
  int n; cin>>n;
   string s; cin>>s;
  int q; cin>>q;
  set<int> v[26];
  rep(i,0,n){
    v[s[i]-'a'].insert(i+1);
  }
  map<int,int> mp;
  while(q--){
    int ch; cin>>ch;
    if(ch==1){
      int i; char c;
       cin>>i>>c;
       rep(j,0,26){
         if(v[j].find(i)!=v[j].end()){
           v[j].erase(i);
           break;
         }
       }
       v[c-'a'].insert(i);
    }
    else{
      int c=0;
      int l,r; cin>>l>>r;
      rep(i,0,26){
        auto it=v[i].lower_bound(l);
        if(it==v[i].end())continue;
        if(*it<=r)c++;
      }
      cout<<c<<"\n";
    }
  }
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 27244
#include <bits/stdc++.h>
 
 
using namespace std;
const long long inf=LONG_MIN;
 
int main(){
	vector <int> v1 , v2;
	vector <long long> V;
	long long maxi=0;
	int N , W , w , v;
	cin>>N>>W;
	V.push_back(0);
	for (int i=1;i<W+1;i++)
		V.push_back(inf);
	
	for (int i=0;i<N;i++){
		cin>>w>>v;
		v1.push_back(w);
		v2.push_back(v);
	}
	
	for (int i=0;i<N;i++)
		for (int j=W;j>=0;j--)
			if (j+v1[i]<=W)
				V[j+v1[i]]=max(V[j+v1[i]], V[j]+v2[i]);
	
	for (int i=W;i>=0;i--)
		if (V[i]>maxi)
			maxi=V[i];
			
	cout<<maxi;
	
	return 0;
}


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

int main() {
    int H, A;
    int N;  //答え

    cin >> H >> A;

    N = H / A;
    if (H % A == 0) {
        cout << N << endl;
    } else {
        cout << N + 1 << endl;
    }
}


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

using namespace std;

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    double xy = pow(fabs(x2 - x1), 2) + pow(fabs(y2 - y1), 2);
    printf("%lf", sqrt(xy));
}


Measured memory_bytes: 3196
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    ll ans = 0;
    REP(i, 3) if (s[i] == t[i]) ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
  int D; cin >> D;
  vector<int> c(26);
  
  int x = 0;
  rep(i, 26){
    cin >> c.at(i);
    if(c.at(x)<=c.at(i)) x = i;
  }
  
  rep(i, D) cout << x+1 << endl;
}

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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
#define fi first
#define se second
#define SZ 1000005
const int mx = 1234567;
const double eps = 1e-8;
const int md = 1e9+7;
const double pi = acos(-1.0);

typedef long long ll;

int dr[8] = {-1,-1,+0,+1,+1,+1,+0,-1};// counter clockwise
int dc[8] = {+0,-1,-1,-1,+0,+1,+1,+1};

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;
pair<int, int>pr[mx];

int ar1[mx],ar2[mx],ar3[mx],ar4[mx];

double ax[mx],bx[mx];

int main(){

    int tk=1,n,m;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);
    int k;
    while(scanf("%d%d",&n,&k) == 2){

        for(int i = 0; i < n; i++){
            scanf("%lf",&ax[i]);
        }
        for(int i = 0; i < n; i++){
            bx[i] = (ax[i] * (ax[i] + 1)) / 2.0;
            bx[i] = bx[i] / ax[i];
        }

//        for(int i = 0; i < n; i++){
//           printf("%.10f ",bx[i]);
//        }cout<<endl;

        int lo = 0, hi = 0;
        double mm = -1.1,x = 0.0;
        while(hi < n){
            if(hi<n && (hi - lo) < k){
                x += bx[hi];
//                cerr<<lo<<": "<<hi<<" "<<x<<endl;
                hi++;
            }else{
                mm = max(mm, x);
                x = x - (bx[lo]);
                lo++;
            }
        }
        mm = max(mm, x);
        printf("%.10f\n",mm);
    }
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b; scanf("%d%d", &a, &b);
	printf("%d\n", max({a+b, a-b, a*b}));
}


Measured memory_bytes: 256
program main
  implicit none

  integer, allocatable, dimension ( : ) :: A, B
  integer :: n, i, j, tmp
  
  read *, n

  allocate ( A ( 1:n ) )
  allocate ( B ( 1:2 ) )

  B = 0
  
  do i = 1, n
     read *, A ( i )
     if ( B ( 1 ) < A ( i ) ) then
        B ( 1 ) = A ( i )
     else if ( B ( 1 ) >= A ( i ) .and. B ( 2 ) < A ( i ) ) then
        B ( 2 ) = A ( i )
     end if
  end do

  do i = 1, n
     if ( A ( i ) == B ( 1 ) ) then
        print *, B ( 2 )
     else
        print *, B ( 1 )
     end if
  end do

end program main


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

int main(){
    int  n;cin>>n;
    map<int,int> ct;
    for(int i=0;i<n;i++){
        int w;cin>>w;
        ct[w]++;
    }
    int num=0;
    for(auto&& w:ct){
        if(w.second%2==1)num++;
    }
    cout<<num<<endl;
}

Measured memory_bytes: 4992
N = int(input())
L = [[0 for j in range(10)] for i in range(10)]
for i in range(1,N+1):
    sentou = int(str(i)[0])
    matsubi = int(str(i)[-1])
    L[sentou][matsubi] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += L[i][j]*L[j][i]

print(ans)

Measured memory_bytes: 41580
import math

a, b, x = map(int,input().split())

if a*a*b/2 <= x:
    h = (a*a*b - x)*2 / (a*a)
    print(math.degrees(math.atan(h/a)))
else:
    h = (2*x) / (a*b)
    print(math.degrees(math.atan(b/h)))

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

int main() {
  int n; cin >> n;
  vector<int> v(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int q; cin >> q;
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    int y; cin >> y;
    v.at(n) = y;
    int j = 0;
    while (y != v.at(j)) {
      j++;
    }
    if (j != n) {
      cnt++;
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3084
def main():
    k = int(input())
    ans = 1
    n = 7%k
    a = [-1 for i in range(k)]
    while True:
        if n==0:
            print(ans)
            return
        if a[n]==-1:
            a[n] = 1
            ans += 1
            n = (n*10+7)%k
        else:
            print(-1)
            return

if __name__ == "__main__":
    main()


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int x = 0, y = 0;
    for(char c : S) {
        if('A' <= c && c <= 'M') y++;
        else if('N' <= c && c <= 'Z') y--;
        else if('a' <= c && c <= 'm') x++;
        else x--;
    }
    cout << abs(y) + abs(x) << endl;
    rep(i, 0, abs(y)) printf("%c", (y > 0 ? 'A' : 'N'));
    rep(i, 0, abs(x)) printf("%c", (x > 0 ? 'a' : 'n'));
    cout << endl;
    return 0;
}



Measured memory_bytes: 3340
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long> X(N),Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i]; Y[i] = X[i];
	}
	sort(Y.begin(), Y.end());
	for (int i = 0; i < N; i++) {
		if (X[i] <= Y[N / 2-1])cout << Y[N / 2] << endl;
		else cout << Y[N / 2-1] << endl;
	}
}


Measured memory_bytes: 5376
s=input()
n=len(s)
at=["A","T","G","C"]
ans=[-1]
for i in range(n-1):
    if s[i] not in at:
        ans.append(i)#-ans[-1])
if s[n-1] in at:
    ans.append(n)
else:
    ans.append(n-1)

m=len(ans)
ans2=[]
for j in range(m-1):
    ans2.append(ans[j+1]-ans[j]-1)

#print(ans)
#print(ans2)

if len(ans)==1:
    print(n)
elif len(ans2)==0:
    print(0)
else:
    print(max(ans2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int a, b; string s;
  cin >> a >> b >> s;
  
  string ans = "Yes";
  rep (i, a+b+1) {
    //   cout << s[i] << endl;
      if (i < a && !isdigit(s[i]))
      {
          cout << "No" << endl;
          return 0;
      }
      if (s[a] != '-')
      {
          cout << "No" << endl;
          return 0;
      }
      if (i > a && !isdigit(s[i]))
      {
          /* code */
          cout << "No" << endl;
          return 0;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int h,w,d;
   cin>>h>>w>>d;
   pint p[h*w];
   rep(i,h)rep(j,w){
       int x;scanf("%d",&x);
       p[--x]={i,j};
   }
   int dist[h*w];
   rep(i,h*w){
       if(i<d)dist[i]=0;
       else dist[i]=dist[i-d]+abs(p[i].first-p[i-d].first)+abs(p[i].second-p[i-d].second);
   }
   int q;
   cin>>q;
   rep(i,q){
       int x,y;
       cin>>x>>y;
       printf("%d\n",dist[y-1]-dist[x-1]);
   }
}

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

int main(){

	int n;
	char arr[101];
	scanf("%d",&n);
	scanf("%s",&arr);
	
	int len = strlen(arr);
	
	if(len > n){
		for(int i=0;i<n;i++){
			printf("%c",arr[i]);
		}
		printf("...");
	}
	else if(len == n || len < n){
		printf("%s",arr);
	}

	

    return 0;
}


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

struct State {
  int pos, money, cost;
  State(int pos,int money,int cost) : pos(pos), money(money), cost(cost) {;}
  State() {;}
  bool operator<(const State s) const {
    return cost > s.cost;
  }
};


const int INF = 1000000000;
int n,m,l,a,b,d,e;

int main() {
  while(cin>>n>>m>>l, n|m|l) {
    l++;
    int cost[n][l], d[n][n], e[n][n];
    bool visited[n][l];
    for(int i=0; i<n; ++i) {
      for(int j=0; j<n; ++j)
	d[i][j] = e[i][j] = INF;

      for(int j=0; j<l; ++j) {
	cost[i][j] = INF;
	visited[i][j] = false;
      }
    }

    for(int i=0; i<m; ++i) {
      int f,to;
      cin>>f>>to;
      f--,to--;
      cin>>d[f][to]>>e[f][to];
      d[to][f] = d[f][to];
      e[to][f] = e[f][to];
    }

    cost[0][l-1] = 0;
    State s(0,l-1,0);

    priority_queue<State> Q;
    Q.push(s);

    while(!Q.empty()) {
      s = Q.top(); Q.pop();
      int nc = s.cost, pos = s.pos, mo = s.money;
      if(visited[pos][mo]) continue;
      visited[pos][mo] = true;

      for(int i=0; i<n; ++i) {
	if(d[pos][i] <= mo && nc < cost[i][mo-d[pos][i]]) {
	  State next(i, mo-d[pos][i], nc);
	  cost[i][mo-d[pos][i]] = nc;
	  Q.push(next);
	}
	if(nc + e[pos][i] < cost[i][mo]) {
	  cost[i][mo] = nc + e[pos][i];
	  State next(i, mo, cost[i][mo]);
	  Q.push(next);
	}
      }
    }

    int ans = INF;
    for(int i=0; i<l; ++i) {
      ans = min(ans, cost[n-1][i]);
    }

    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

pll a[100005];ll b[100005],c[100005];
int main()
{ios_base::sync_with_stdio(false);
ll l,n,t,s=0;
cin>>n>>l>>t;
rep(i,0,n-1)
{
	cin>>a[i].ff;
	a[i].ss=i;
	int x;
	cin>>x;
	if(x==1)
	b[i]=(a[i].ff+t)%l,s+=t;
	else
	b[i]=((a[i].ff-t)%l+l)%l,s-=t;
}
sort(b,b+n);
//sort(a,a+n);


rep(i,0,n-1)s+=a[i].ff-b[i];

s%=(l*n);
if(s<0)s+=l*n;
ll kk=s/l;


rep(i,0,n-1)
{
	ol(b[(i+kk)%n]);on;
}

return 0;
}


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

using namespace std;

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

    vector<int> A(n);

    pair<int,int> one(0,0);
    int two;
    
    for(i=0; i<n; i++){

        cin >> A.at(i);
            if(one.first <= A.at(i)){
                two = one.first;
                one.first = A.at(i);
                one.second = i;
            }else if(two <= A.at(i)){
                two = A.at(i);
            }

    }

    for(i=0; i<n; i++){
        if(i == one.second){
            cout << two << endl;
            continue;
        }
        cout << one.first << endl;
    }

    return 0;
}

Measured memory_bytes: 4048
def main():
    N = int(input())
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    ans = 0; cnt = 0
    for i in range(N):
        cnt += sum(A1[:i]) + A1[i]
        cnt += sum(A2[i:])
        ans = max(ans, cnt)
        cnt = 0
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,d,x,a;
  cin >> n >> d >> x;
  ll co =0;
  rep(i,n){
    cin >> a;
    for(ll j=1;j<=d;j+=a){
      co++;
    }
  }
  pri(x+co);
  return 0;
}



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

int main()
{
    long long n,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    while(n--){
    string s;cin>>s;
    if(s=="AC")ac++;
    else if(s=="WA")wa++;
    else if(s=="TLE")tle++;
    else re++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int i;
    multiset< int > s;
    int nn = 0, np = 0;
    FOR0(i, n)
    {
        int temp;
        cin>>temp;
        if(temp < 0)  nn++;
        else np++;
        s.insert(temp);
    }
    multiset< int >::iterator it;
    vii out;
    if(np == 0)
    {
        if(s.size() > 2)
        {
            it = s.begin();
            int left = *it;
            s.erase(it);
            it = s.end();
            it --;
            int right = *it;
            int num = 0;
            s.erase(it);
            num = right - left;
            out.pb(ii(right, left));
            np++;
            nn -= 2;
            s.insert(num);
        }
    }
    if(nn!=0&&np!=0)
    {
        while(nn > 1 && s.size()>2)
        {
            it = s.begin();
            int left = *it;
            s.erase(it);
            it = s.end();
            it --;
            int right = *it;
            int num = 0;
            s.erase(it);
            num = right - left;
            out.pb(ii(right, left));
            nn--;
            s.insert(num);
        }
    }
    while(s.size() > 2)
    {
        it = s.begin();
        int left = *it;
        s.erase(it);
        it = s.end();
        it --;
        int right = *it;
        int num = 0;
        s.erase(it);
        num = left - right;
        out.pb(ii(left, right));
        s.insert(num);
    }
    it = s.begin();
    int left = *it;
    s.erase(it);
    it = s.end();
    it --;
    int right = *it;
    out.push_back(ii(right, left));
    int ans = (right - left);
    int si = out.size();
    cout<<ans<<endl;
    FOR0(i, si)
    {
        cout<<out[i].ff<<" "<<out[i].ss<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 7416
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	vector<ll> T(N+1);
	for (int i = 1; i <= N; i++)cin >> T[i];

	ll M; cin >> M;
	vector<ll> P(M+1), X(M+1);
	for (int i = 1; i <= M; i++) {
		cin >> P[i] >> X[i];
	}

	ll sum = 0;
	for (int i = 1; i <= N; i++)sum += T[i];

	for (int i = 1; i <= M; i++) {
		cout << sum - T[P[i]] + X[i] << endl;;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

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

  scanf("%d",&n);

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

  for(i = 0; i < n-1; i++)
    {
      if(a[i] > a[i+1])flag = 1;
    }

  while(flag == 1)
    {
      flag = 0;
      
      for(i = 0; i < n; i++)
	{
	  for(j = n-1; j > i; j--)
	    {
	      if(a[j] < a[j-1])
		{
		  temp = a[j];
		  a[j] = a[j-1];
		  a[j-1] = temp;
		  count++;
		  flag = 1;
		}
	    }
	}
    }
  
  for(i = 0; i < n-1; i++)
    {
      printf("%d ",a[i]);
    }
  
  printf("%d\n",a[n-1]);
  printf("%d\n",count);
  
  return 0;
}



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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

pair<int, int> d[114514];
vector<int> tokei, hant;

int ans[114514];

signed main() {
  int n, l, t;
  cin >> n >> l >> t;
  l *= n + 1;
  t *= n + 1;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    a = a * (n + 1) + i + 1;
    d[i] = make_pair(a, b);
    if(b == 1) {
      tokei.push_back(a);
    }
    else {
      hant.push_back(a);
    }
  }
  rep(i, n) {
    if(d[i].second == 1) {
      int nb = (d[i].first + t * 2) % l;
      int ns = (d[i].first + t * 2) / l;
      int a = i + hant.size() * ns + distance(hant.begin(), lower_bound(hant.begin(), hant.end(), nb)) - distance(hant.begin(), lower_bound(hant.begin(), hant.end(), d[i].first));
      ans[a % n] = (d[i].first + t) % l;
    }
    else {
      int nb = ((d[i].first - t * 2) % l + l) % l;
      int ns = (l - d[i].first + t * 2) / l;
      int a = i - tokei.size() * ns - (tokei.size() - distance(tokei.begin(), lower_bound(tokei.begin(), tokei.end(), nb))) + (tokei.size() - distance(tokei.begin(), lower_bound(tokei.begin(), tokei.end(), d[i].first)));
      ans[(a + n * inf) % n] = ((d[i].first - t) % l + l) % l;
    }
  }
  rep(i, n) {
    cout << ans[i] / (n + 1) << endl;
  }
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A, B;
  cin >> A >> B;
  if(A <= 5)
    cout << 0 << endl;
  else if(A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
4 5
1 2
1 3
3 2
2 4
3 4
*/
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mpr make_pair
#define MX 1000000007
#define ui unsigned int
#define ll long long
#define ld long double
#define fi first
#define se second
#define testcases int testcases;cin>>testcases;while(testcases--)
#define printvector(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl
#define printarray(v,n)  for(int i=0;i<n;i++) cout<<v[i]<<" ";  cout<<endl
#define inputarray(v,n)  for(int i=0;i<n;i++)cin>>v[i]
#define debug(i) cout<<"debug: "<<i<<endl
#define pr(i) cout<<i<<endl
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


class graph{
    unordered_map<int,vector<int>> adjList;
    int n;
public:
    graph(int n){
        this->n = n;
    }
    void addEdge(int a, int b){
        adjList[a].pb(b);
    }
    
    int dfs(int from, vector<int>&dp){
        if(dp[from] != -1)return dp[from];
        int mx = 0;
        for(auto to : adjList[from]){
            mx = max(mx, dfs(to,dp));
        }
        return dp[from] = 1 + mx;
    }
};


int main() {
    fast_io
    int n,m;
    cin>>n>>m;
    graph g(n);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        g.addEdge(a,b);
    }
    //vector<bool>vis(n,0);
    vector<int>dp(n+1,-1);

    for(int i=1;i<=n;++i){
        if(dp[i]==-1) 
            g.dfs(i,dp);
    }

    
    int ans = 0;
    for(int i=1;i<=n;++i){
        ans = max(ans,dp[i]);
    }
    pr(ans-1);

}

Measured memory_bytes: 10660
#include <iostream>
#include <string>
#include <queue>

using namespace std;
struct Point{
  int x;int y;
};

int main(){
  int w,h,i,j,k,c=0;
  string str;
  Point p,b;
  cin >> w >> h;
  while(w!=0&&h!=0){
    c=1;
    int dp[21][21]={{}};
    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	if(str[j]=='.') dp[j][i]= 1;
	if(str[j]=='#') dp[j][i]= 2;
	if(str[j]=='@') {
	  dp[j][i]= 3;
	  p.x=j;p.y=i;
	}
      }
    }
    
    queue <Point> q;
    q.push(p);
    while(!q.empty()){
      p = q.front();
      q.pop();
      if((p.x+1)<w&&dp[p.x+1][p.y]==1){
	c++;
	b.x=p.x+1;b.y=p.y;
	dp[p.x+1][p.y]=-1;
	q.push(b);
      }
      if((p.x-1)>=0&&dp[p.x-1][p.y]==1){
	c++;
	b.x=p.x-1;b.y=p.y;
	dp[p.x-1][p.y]=-1;
	q.push(b);
      }
      if((p.y+1)<h&&dp[p.x][p.y+1]==1){
	c++;
	b.x=p.x;b.y=p.y+1;
	dp[p.x][p.y+1]=-1;
	q.push(b);
      }
      if((p.y-1)>=0&&dp[p.x][p.y-1]==1){
	c++;
	b.x=p.x;b.y=p.y-1;
	dp[p.x][p.y-1]=-1;
	q.push(b);
      }
    }
    cout << c << endl;
    cin >> w >> h;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int main(void)
{
	int A[100][100], b[100], Ab[100] = {0};
	int n, m,i,j;

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d ", &A[i][j]);
		}
	}

	for (i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0;j < m; j++)
		{
			Ab[i] += A[i][j] * b[j];
		}

		printf("%d\n", Ab[i]);
	}

	return 0;
}


Measured memory_bytes: 2112
package main

import "fmt"

func main() {
	var X, Y , r int
	fmt.Scan(&X, &Y)

	for i:=0; i<2; i++ {
		if X >= Y {
			r += X
			X--
		} else {
			r += Y
			Y--
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>

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

	std::vector<int> sqList(18);
	sqList[0]=1;
	for(int i=1; i<18; i++)
		sqList[i]= sqList[i-1]*2;

	double coef= 1.0/n;
	double ans= 0.0;

	for(int i=1; i<=n; i++){
		int tmp= i;
		int times= 0;

		while(tmp<k){
			tmp= tmp*2;
			times++;
		}

		ans+= 1.0/ (double)(sqList[times]);

	}

	std::cout<<std::setprecision(10)<<ans*coef<<std::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);
        int n = sc.nextInt();
        String line = sc.next();

        int r = 0;
        int b = 0;
        for (int i = 0;i < n;i++){
            if(line.charAt(i) == 'R'){
                r++;
            } else {
                b++;
            }
        }

        if(r > b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; ll b; ll c;
    cin >> a >> b >> c;
    vector <ll> ns = {a, b, c};
    sort(ns.begin(), ns.end());
    if ((ns[0] == ns[1]) ^ (ns[1] == ns[2])){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin>>s;
 if(s=="Sunny")
 cout<<"Cloudy"<<endl;
 else if(s=="Cloudy")
 cout<<"Rainy"<<endl;
 else
 cout<<"Sunny"<<endl;
 return 0;
}



Measured memory_bytes: 256
a, b, m = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
waribiki = [list(map(int, input().split())) for i in range(m)]
ans = min(alist) + min(blist)
for i in range(m):
    if ans > alist[waribiki[i][0] - 1] + blist[waribiki[i][1] - 1] - waribiki[i][2]:
        ans = alist[waribiki[i][0] - 1] + blist[waribiki[i][1] - 1] - waribiki[i][2]
print(ans)

Measured memory_bytes: 38560
#include<stdio.h>
int main(){
	int i,j,t,n,x,s;
	while(scanf("%d %d",&n,&x)!=EOF&&n+x){
		s=0;
		for(i=1;i<=n;i++)
			for(j=i+1;j<=n;j++)
				for(t=j+1;t<=n;t++)
					if(i+j+t==x) s++;
		printf("%d\n",s);
	}
	return 0;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll  n;
	cin >> n;
	range(a, 1, 3500) {
		range(b, 1, 3500) {
			if ((4 * a*b - n*(a + b))!=0&&(n*a*b) % (4 * a*b - n*(a + b)) == 0&& (n*a*b) / (4 * a*b - n*(a + b))>0) {
				cout << a << " " << b << " " << (n*a*b) / (4 * a*b - n*(a + b));
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t value[3];
	cin >> value[0] >> value[1] >> value[2];

	int32_t cnt5 = 0, cnt7 = 0;
	for (int32_t i = 0; i < 3; i++) {
		if (value[i] == 5)
			cnt5++;
		else if (value[i] == 7)
			cnt7++;
	}
	cout << (cnt5 == 2 && cnt7 == 1 ? "YES" : "NO") << endl;

	return 0;
}


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

int main() {

    int n;
    cin >> n;

    vector<int> vec(n);

    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    int pre_n = 1;

    int flg = 0;

//    for(auto i=vec.begin(); )

    for (int i = 0; i < n; i++) {
        if (vec.at(i) == 1) {
            flg += 1;
        }
        if (vec.at(i) == pre_n) {
            pre_n += 1;
//            continue;
        }
//        else if (vec.at(i) != pre_n) {
//            vec.erase(vec.begin() +i);
////            vec.push_back()
//            continue;
//        }
    }

    if (flg) {
        cout << n - pre_n + 1;
    }
    else {
        cout << -1;
    }


// TODO:
// until find 1 ok remove previous num
// count remove num
// then find 2 ... remove previous num
// go to last
// check i = n
// if i = n => cout count
// if i != n => cout -1


    return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int h,w,n; cin >> h >> w >> n;
  
  int ans;
  for(ans=0;;ans++) {
    if(ans*max(h,w)>=n) { break; }
  }

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


Measured memory_bytes: 3492
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
const int Maxn = int(1e6);
const ll Mod = (ll)(1e9) + 7;
int prime[Maxn + 5];
int n;

void Era(){
    for (int i = 2; i <= Maxn; i++)
        if (prime[i] == 0){
            prime[i] = i;
            if (i <= 1000){
                for (int j = i*i; j <= Maxn; j += i) prime[j] = i;
            }
        }
}

ll fastpow(ll x,ll y = Mod - 2){
    ll ans = 1;
    while (y){
        if (y & 1) ans = (ans * x) % Mod;
        x = (x * x) % Mod;
        y >>= 1;
    }
    return ans;
}

ll LCM(const vector<int>& x){
    Era();
    unordered_map<int,int> power;
    for (int num: x){
        unordered_map<int,int> tmp;
        int u = num;
        while (u > 1){
            tmp[prime[u]]++;
            u /= prime[u];
        }
        for (auto it: tmp)
            power[it.first] = max(power[it.first],it.second);
    }

    ll ans = 1;
    for (auto it: power)
        ans = (ans*fastpow(it.first,it.second)) % Mod;
    return ans;
}


int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    
    // factor xi/yi = a1/ai = bi/b1
   
    ll Lcm = LCM(a);
    //cout << Lcm << '\n';
    ll ans = 0;
    for (int x: a) 
        ans = (ans + (fastpow(x)*Lcm) % Mod ) % Mod;

    cout << ans; 
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll sum = a + b;
  ll ans = (n / sum) * a;
  ans += min((n % sum), a);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a>b) {
			System.out.println(0);
		}else {
			if(a*c > b) {
				System.out.println(b/a);
			}else {
				System.out.println(c);
			}
		}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  if((a + b) % 2 == 0)cout << (a+b)/2 << endl;
  else cout << (a + b) / 2 + 1 << endl;
}


Measured memory_bytes: 3596