akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <bits/stdc++.h>
 
using namespace std;
using namespace  __gnu_pbds;
 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
typedef pair<int,int> pr; 
 
const ll MOD = 1e9 + 7,OOl=LLONG_MAX;
const int N = 1e6+1, M = 1e6+1, OO = INT_MAX,OOmem = 0x4f4f4f4f;
 
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);}
 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  if(ch!='-') while (!isdigit(ch) && ch!=EOF) ch= (char) getchar_unlocked(), minus = (ch == '-'? -1 : minus);
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char (&x)[N]) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
int cost[N],dp[N],n,k;
int main()
{
  
  READn(n),READn(k);
  for(int i=0;i<n;++i) READn(cost[i]),dp[i]=OO;
  dp[0] = 0;
  for(int i=1;i<n;++i)
  {
    for(int j=1;j<=k;++j) if(i-j>=0) dp[i] = min(dp[i],dp[i-j]+abs(cost[i]-cost[i-j])); 
    
  }
  
  WRITEn(dp[n-1]);
  return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N;
  int ans = 0;
  rep(i,N){
    int x; cin >> x;
    ans += x-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
r=int(input())
c=int(input())
n=int(input())
if n%r==0:
    t=n//r
else:
    t=n//r+1
if n%c==0:
    s=n//c
else:
    s=n//c+1

if t>s:
    print(s)
else:
    print(t)

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P;

int main()
{
    int n, m;
    cin >> n;
    map<string, int> point;
    rep(i, n)
    {
        string s;
        cin >> s;
        if (!point.count(s)) {
            point[s] = 1;
        } else {
            point.at(s) += 1;
        }
    }
    cin >> m;
    rep(i, m)
    {
        string t;
        cin >> t;
        if (!point.count(t)) {
            point[t] = -1;
        } else {
            point.at(t) -= 1;
        }
    }

    int ans = -INF_32;
    for (auto key : point) {
        if (key.second > ans) {
            ans = key.second;
        }
    }

    cout << max(0, ans) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    
    if(op.equals("+")) System.out.println(a+b);
    else System.out.println(a-b);

  }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    
    vector<int> item(n);
    for(int i = 0; i < n; i++){
        cin >> item[i];
    }
    sort(item.rbegin(), item.rend());
    item[0] /= 2;
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += item[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

struct P{
    double p;
    double q;
    int r;
    int b;
    P(){}
    P(double p1,double p2,int p3,int p4){
        p=p1;
        q=p2;
        r=p3;
        b=p4;
    }
};

int N;
double R,B;
vector<P> S;
bool cone[110];

int GCD(int a,int b){
    return b?GCD(b,a%b):a;
}

int LCM(int a,int b){
    return a*b/GCD(max(a,b),min(a,b));
}

int dfs(int n){
    if(n==-1)return 1;
    int R = dfs(S[n].r)*S[n].p;
    int B = dfs(S[n].b)*S[n].q;
    int lcm = LCM(R,B);
    return lcm/S[n].p+lcm/S[n].q;
}

signed main(){
    while(1){
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;++i){
            int p,q,r,b;
            cin>>p>>q>>r>>b;
            r--;
            b--;
            cone[r]=true;
            cone[b]=true;
            S.PB(P(p,q,r,b));
        }
        for(int i=0;i<N;++i){
            if(!cone[i]){
                cout<<dfs(i)<<endl;
                break;
            }
        }
        S.clear();
        memset(cone,0,sizeof(cone));
    }
    return 0;
}

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

#define MAXN 100111

bool solve(int ans[], int a[], int n)
{
    for(int i = 2; i <= n + 1; ++i)
    {
        if(ans[i - 1] == 1)
            ans[i] = a[i - 1] ? ans[i - 2] : 1 - ans[i - 2];
        else
            ans[i] = ( 1 - a[i - 1] ) ? ans[i - 2] : 1 - ans[i - 2];
    }

    return ans[0] == ans[n] && ans[1] == ans[n + 1];
}

int main()
{

    int n;
    cin >> n;
    string s;
    cin >> s;
    int a[MAXN];
    for(int i = 0; i < n; ++i)
        a[i] = s[i] == 'o' ? 1 : 0;
    a[n] = a[0];
    a[n + 1] = a[1];

    int ans[MAXN];
    for(int i = 0; i < 4; ++i)
    {
        ans[0] = i / 2;
        ans[1] = i % 2;
        if(solve(ans, a, n) )
        {
            for(int j = 0; j < n; ++j)
                cout << ( ans[j] ? 'S' : 'W' );
            cout << "\n";
            return 0;
        }
    }

    cout << "-1\n";
    return 0;
}


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

int main()
{
    string str;
    cin >> str;
    vector<int> lis(26,0);
    for(int i = 0; i < str.size(); i++){
        lis[str[i]- 'a']++;
    }

    bool ex = true;

    for(int i = 0; i < 26; i++){
        if(lis[i] >= 2){
            ex = false;
            break;
        }
    }

    if(ex) cout << "yes" << endl;
    else cout << "no" << endl;
}

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

class Node {
public:
  int location;
  int p, l, r;
  Node() {}
};

class Point {
public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y): id(id), x(x), y(y) {}
  bool operator < ( const Point &p) const {
    return id < p.id;
  }

  void print() {
    printf("%d\n", id);  // cout より高速な printf 関数を使用
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth) {
  if ( !(l < r) ) return NIL;
  int mid = ( l + r ) / 2;
  int t = np++;
  if ( depth % 2 == 0 )
    sort(P + l, P + r, lessX);
  else
    sort(P + l, P + r, lessY);
  T[t].location = mid;
  T[t].l = makeKDTree(l, mid, depth + 1);
  T[t].r = makeKDTree(mid + 1, r, depth + 1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans ) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if ( sx <= x && x <= tx && sy <= y && y <= ty )
    ans.push_back(P[T[v].location]);

  if ( depth % 2 == 0 ) {
    if ( T[v].l != NIL )
      if ( sx <= x ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    if ( T[v].r != NIL )
      if ( x <= tx ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
  } else {
    if ( T[v].l != NIL )
      if ( sy <= y ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    if ( T[v].r != NIL )
      if ( y <= ty ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
  }
}

int main() {
  int x, y;
  scanf("%d", &N);
  for ( int i = 0; i < N; i++ ) {
    scanf("%d %d", &x, &y);  // cin より高速な scanf 関数を使用
    P[i] = Point(i, x, y);
    T[i].l = T[i].r = T[i].p = NIL;
  }

  np = 0;

  int root = makeKDTree(0, N, 0);

  int q;
  scanf("%d", &q);
  int sx, tx, sy, ty;
  vector<Point> ans;
  for ( int i = 0; i < q; i++ ) {
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    ans.clear();
    find(root, sx, tx, sy, ty, 0, ans);
    sort(ans.begin(), ans.end());
    for ( int j = 0; j < ans.size(); j++ )
      ans[j].print();
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 15852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll k;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k;
    cout <<50 << "\n";
    for(int i=0;i<50;i++){
        if(k%50>=i+1)
        cout<<i+k/50+50-k%50+1<<" ";
        else
        cout<<i+k/50-k%50<<" ";  
    }
    cout<<"\n";  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  int r;
  if(x>y) swap(x,y);
  r=y%x;
  while(r>0){
    y=x;
    x=r;
    r=y%x;
  }
  return x;
}
int main(){
  int x,y,z,w;
  cin>>x>>y>>z;
  w=gcd(x,y);
  if(z%w==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3624
#AGC040
import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for _ in range(n+1)]

for i in range(n):
    if s[i] == '<':
        L[i+1] = L[i] +1

#print(L)

for i in range(n-1,-1,-1):
    if s[i] == '>':
        L[i] = max(L[i], L[i+1]+1)

#print(L)

print(sum(L))

Measured memory_bytes: 24236
# -*- coding: utf-8 -*-
 
# t, s = map(str,input().split())

n = int(input())
str_a = input().split()

a = []
for i in range(len(str_a)):
    a.append(int(str_a[i]))

total = 0
c = 0
for i in range(n - 1):
    c += a[-i]
    total += c * a[-(i + 1)]

print(total % (1000000007))

Measured memory_bytes: 31680
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int h,w;
vector<vector<int>> d;

void make_way(int i, int j, int s, int t){
	d[i*w+j][s*w+t] = 1;
	d[s*w+t][i*w+j] = 1;
}

int main(){
	cin >> h >> w;
	const int INF = 1<<20;
	REP(i,h*w){
		vector<int> tmp(h*w,INF);
		d.push_back(tmp);
	}
	vector<string> s(h);
	REP(i,h){
		cin >> s[i];
	}
	REP(i,h*w) d[i][i] = 0;
	
	REP(i,h){
		REP(j,w){
			if(s[i][j]=='#') continue;
			if(i!=0 && s[i-1][j]=='.') make_way(i,j,i-1,j);
			if(j!=0 && s[i][j-1]=='.') make_way(i,j,i,j-1);
			if(i!=h-1 && s[i+1][j]=='.') make_way(i,j,i+1,j);
			if(j!=w-1 && s[i][j+1]=='.') make_way(i,j,i,j+1);
		}
	}
	
	REP(k,h*w){
		REP(i,h*w){
			REP(j,h*w){
				chmin(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
	
	int ans=0;
	REP(i,h*w){
		REP(j,h*w){
			if(d[i][j]!=INF) chmax(ans, d[i][j]);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4268
import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        String first = rd.readLine();
        String second = rd.readLine();
        int[][] arr = new int[first.length()][second.length()];
        int[][] arr2 = new int[first.length()][second.length()];
        int[][] arr3 = new int[first.length()][second.length()];

        if (first.charAt(0) == second.charAt(0)) {
            arr[0][0] = 1;
        }
        arr2[0][0] = -1;
        arr3[0][0] = -1;
        
        for (int i = 1; i < arr.length; i++) {
        	if (first.charAt(i) == second.charAt(0)) {
        		arr[i][0] = 1;
	        	arr2[i][0] = -1;
	        	arr3[i][0] = -1;
        	} else {
        		arr[i][0] = arr[i - 1][0];
        		arr2[i][0] = i - 1;
        		arr3[i][0] = 0;
        	}
        }
        for (int i = 1; i < arr[0].length; i++) {
        	if (first.charAt(0) == second.charAt(i)) {
        		arr[0][i] = 1;
	        	arr2[0][i] = -1;
	        	arr3[0][i] = -1;
        	} else {
        		arr[0][i] = arr[0][i - 1];
        		arr2[0][i] = 0;
        		arr3[0][i] = i - 1;
        	}
        }

        for(int i = 1; i < arr.length; i++) {
            for (int j = 1; j < arr[0].length; j++) {
                int prev = arr[i - 1][j];
                int prev2 = arr[i][j - 1];
                if (first.charAt(i) == second.charAt(j)) {
                   arr[i][j] = arr[i - 1][j - 1] + 1;
                   arr2[i][j] = i - 1;
                   arr3[i][j] = j - 1;
                } else {
                    if (prev >= prev2) {
                    	arr[i][j] = prev;
                    	arr2[i][j] = i - 1;
                    	arr3[i][j] = j;
                    } else {
                    	arr[i][j] = prev2;
                    	arr2[i][j] = i;
                    	arr3[i][j] = j - 1;
                    }
                }
            }
        }


        StringBuilder s = new StringBuilder();
        int lastI = arr.length - 1;
        int lastJ = arr[0].length - 1;
        while (true) {
            if (lastI == -1 || lastJ == -1) {
                break;
            }
            if (first.charAt(lastI) == second.charAt(lastJ)) {
                s.append(first.charAt(lastI));
            }

            int tmp = lastI;
            lastI = arr2[lastI][lastJ];
            lastJ = arr3[tmp][lastJ];
            if (lastI == -1 || lastJ == -1) {
                break;
            }
//            System.out.println(first.charAt(lastI) + " " + second.charAt(lastJ) + " " + s.toString());
        }
        BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out));
        wr.append(s.reverse());
        wr.flush();
    }

}

//abrac
//avad


Measured memory_bytes: 166996
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>

using namespace std;

// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);

bool isRainy(char c)
{
    return c == 'R';
}

void solve()
{
    string s;
    cin >> s;
    if(isRainy(s[1]))
    {
        if(isRainy(s[0]) && isRainy(s[2])) cout << 3;
        else if(isRainy(s[0]) || isRainy(s[2])) cout << 2;
        else cout << 1;
    }
    else if(isRainy(s[0]) || isRainy(s[2])) cout << 1;
    else cout << 0;
    cout << '\n';
}

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

    int nCases = 1;
    // cin >> nCases;

    while(nCases--)
        solve();

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 1e5 + 10;
int K, a[maxn]; ll L, R;

int main()
{
	K = read();
	for (int i = 1; i <= K; i ++) a[i] = read();
	L = R = 2;
	for (int i = K; i >= 1; i --)
	{
		if (L / a[i] == R / a[i] && L % a[i] && R % a[i])
		{
			puts("-1"); return 0;
		}
		L = (ll)(L / a[i] + (L % a[i] != 0)) * a[i];
		R = (ll)R / a[i] * a[i] + a[i] - 1;
	}
	printf("%lld %lld\n", L, R);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S){
  REP(S.size()){
    cout<<'x';
  }
  cout<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
	ll w,a,b;
	cin>>w>>a>>b;
	if(a>b){
		if(w+b>=a){
			cout << 0<<endl;
		}
		else{
			cout << a-w-b<<endl;
		}
	}
	else{
		if(w+a>=b){
			cout << 0<<endl;
		}
		else{
			cout << b-w-a<<endl;
		}
	}
 	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll r, d, x;

void solve()
{
    cin >> r >> d >> x; ll a[12]; a[0] = x;
    for (int i=1; i<=10; i++) {
        a[i] = r*a[i-1] - d;
        nout(a[i]);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
 public static void main(String[] args)throws IOException {
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     
     while(true){
         String str=br.readLine();
      if(str.equals("0"))break;
         int t=0;
         for(int i=0;i<str.length();i++){
           t+=Character.getNumericValue(str.charAt(i));
         }System.out.println(t);
     }
 }
}

Measured memory_bytes: 24596
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, 0, n) cin >> l[i];
  int sum = 0;
  sort(l.begin(), l.end());
  rep(i, 0, k) sum += l[n-i-1];
  cout << sum << "\n";
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
	int a,b,c,d,e,t;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	
	if(a>b){
		a=b;
	}
	if(a>c){
		a=c;
	}
	if(d>e){
		d=e;
	}
	
	t=a+d-50;

	printf("%d\n",t);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> p;

int main() {
    long long n,m; cin >> n >> m;
    vector<long long> a(n);
    for(int i = 0; i < n; i ++) cin >> a[i];
    vector<p> bc(m);
    for(int i = 0; i < m; i ++) {
        long long b, c; cin >> b >> c;
        bc[i] = make_pair(c,b);
    }
    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end());
    long long sum = 0;
    for(int i = 0; i < n; i ++) {
        if(bc.back().first<= a[i] || bc.empty()) sum += a[i];
        else {
            sum += bc.back().first;
            bc.back().second --;
            if(bc.back().second == 0) bc.pop_back();
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Map<Character, Integer> cache = new HashMap<>();

        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (!cache.containsKey(c)) {
                cache.put(c, 1);
            }
            else {
                cache.put(c, cache.get(c) + 1);
            }
        }

        boolean beautiful = true;
        for (int count : cache.values()) {
            if (count % 2 != 0) {
                beautiful = false;
                break;
            }
        }
        System.out.println(beautiful ? "Yes" : "No");
    }
}


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

int main() {
    int a , b , c , d;
    cin >> a >> b >> c >> d;

    if(a + b == c + d){
        cout << "Balanced" << endl;
    }else if(a + b < c + d){
        cout << "Right" << endl;
    }else{
        cout << "Left" << endl;
    }
}

Measured memory_bytes: 3496
package main

import "fmt"

func main() {
	c := make([][]int, 3)
	for i := 0; i < 3; i++ {
		c[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&c[i][j])
		}
	}
	isOK := true
	for i := 0; i <= 1; i++ {
		for j := 0; j <= 1; j++ {
			if c[i][j+1]-c[i][j] != c[i+1][j+1]-c[i+1][j] {
				isOK = false
				break
			}
		}
	}
	for i := 0; i <= 1; i++ {
		for j := 0; j <= 1; j++ {
			if c[i+1][j]-c[i][j] != c[i+1][j+1]-c[i][j+1] {
				isOK = false
				break
			}
		}
	}
	if isOK {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
// #include<bits/stdc++.h>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
 
typedef long long ll;
#define For(i,x,y) for(int i=x; i<y; ++i)
#define mem(x,y) memset(x,y,sizeof(x))
#define ALL(a) a.begin(),a.end()
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define se second
#define fi first
#define endl '\n'

template <typename T>
inline void read(T &r){
    static char c; r=0; int f=1;
    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 
    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());
    r*=f;
} // -_-

const int N = 1e3 + 105;

int main(){
    ll n;
    scanf("%lld", &n);
    printf("%lld\n", (1 + n)*n/2 - n);
    // system("pause");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stack>
#include<string>

using namespace std;

int main(){

    stack<int> S;
    string s;
    int a, b, c;

    while(cin >> s){
        if(s[0] == '\n') break;
        if(s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            c = b + a;
            S.push(c);
        }else if(s[0] == '-'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            c = b - a;
            S.push(c);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            c = b * a;
            S.push(c);
        
        }else{
            S.push(atoi(s.c_str())); 
        }
    
    }

    cout << S.top() << endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int a,b,c;
    cin>>a>>b;
    cout<<6-(a+b);
    
    return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */





signed main(){


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


    int n = input();
    vi arr; rep(i,0,n) arr.push_back(input());

    vi a; rep(i,1,n + 1) a.push_back(30000 * i);
    vi b; revrep(i,n, 0) b.push_back(30000 * i);

    rep(i,0,n){
        b[arr[i] - 1] += i;
    }

    rep(i,0,n){
        cout << a[i] << (i == n - 1 ? "" : " ");
    }
    cout << endl;

    rep(i,0,n){
        cout << b[i] << (i == n - 1 ? "" : " ");
    }
    cout << endl;



    


    

}



Measured memory_bytes: 1276
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    string s;
    std::cin >> s;
    ll n = s.length();
    for (int i = 0; i < n-1; i++) {
        if(s[i] == s[i+1]){
            std::cout << i+1<<" "<<i+2 << std::endl;
            return 0;
        }
    }
    for (int i = 0; i < n-2; i++) {
        if(s[i] == s[i+2]){
            std::cout << i+1<<" "<<i+3 << std::endl;
            return 0;
        }
    }
    std::cout << -1<<" "<<-1 << std::endl;
}




Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

long long int power2(long long int n){
	if(n == 0) return 1;
	long long int ans = 1;
	for(int i = 0; i < n; i++){
		ans = ans * 2;
	} 
	return ans;
}
int main()
{
	long long int N;
	long long int devidedNumber = 0;
	cin>>N;
	while(N != 1){
		N = N / 2;
		devidedNumber++;
		//cout<<N<<" : "<<devidedNumber<<endl;
	}
	cout<<power2(devidedNumber + 1) - 1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
#include <limits>
#include <type_traits>
#include <vector>

using namespace std;

int main(void) {

    int n , cnt = 1;
    string s;

    cin >> n;
    cin >> s;


    for (int i = 1; i < n; i++ ) {
        if ( s[i] != s[i - 1]) {
            cnt++;
        }  
    }

    cout << cnt;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V;

int main(){
  cin >> N >> S;
  rep(i,N-2){
    if(S.substr(i,3)=="ABC"){
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-24 14:56:05
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

using pll = pair<int64, int64>;

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

  int N; int64 W; cin >> N >> W;

  vector<int64> v(N), w(N);
  for (int i = 0; i < N; ++i) cin >> v[i] >> w[i];
  
  vector<pll> fv, bv;
  
  for (int bit = 0; bit < (1 << (N / 2)); ++bit) {
    int64 tv = 0, tw = 0;
    for (int i = 0; i < N / 2; ++i) {
      if (bit & (1 << i)) {
        tv += v[i], tw += w[i];
      }
    }
    fv.emplace_back(tw, tv);
  }

  for (int bit = 0; bit < (1 << (N - N / 2)); ++bit) {
    int64 tv = 0, tw = 0;
    for (int i = 0; i < N - N / 2; ++i) {
      if (bit & (1 << i)) {
        tv += v[i + N / 2], tw += w[i + N / 2];
      }
    }
    bv.emplace_back(tw, tv);
  }
  // {weight, value}
  sort(all(fv));
  sort(all(bv));

  debug(fv, bv);

  int m = bv.size();
  vector<int64> mx(m, 0);

  mx[0] = bv[0].second;
  for (int i = 1; i < m; ++i) {
    mx[i] = max(mx[i - 1], bv[i].second);
  }

  const int64 inf = 1e18;

  int64 ans = 0;

  for (auto e : fv) {
    int pos = distance(bv.begin(), upper_bound(all(bv), (pll){W - e.first + 1, -inf}));
    --pos;
    if (pos < 0) continue;
    ans = max(ans, e.second + mx[pos]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 43784
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/09.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]&&a[i]!=c[i]&&b[i]!=c[i])
            cnt+=2;
        else if(a[i]==b[i]&&a[i]==c[i])
            continue;
        else
            cnt++;
    }
    cout<<cnt<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
function calcultateGCD(a,b,res) {
	if(a==b)
		return a*res;
    else if ((a&1)==0 && (b&1)==0) 
    	return calcultateGCD(a>>1, b>>1, res<<1);	
    else if ((a&1)==0) 
    	return calcultateGCD(a>>1, b, res); 
    else if ((b&1)==0) 
    	return calcultateGCD(a, b>>1, res); 
    else if (a>b) 
    	return calcultateGCD(a-b, b, res);
    else 
    	return calcultateGCD(a, b-a, res); 
}

function calcultateLCM(a,b,gcd) {
	  return a*b/gcd;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

if(lines.length > 50) {
	console.log("Invalid dataset size. Dataset size is "+lines.length+" but must be <= 50");
} else {
	for (var i = 0; i < lines.length; i++) {
		var line = lines[i].trim();
	    if (line == '') break;
	    var vals = line.split(' ').map(function(i){return +i;});
	    if(vals.length != 2 || isNaN(vals[0]) || isNaN(vals[1]) || vals[0] < 0 || vals[0] > 2000000000 || vals[1] < 0 || vals[1] > 2000000000) {
	    	console.log("Invalid dataset: "+line+ ". Use 0 <= a, b <= 2,000,000,000");
	    } else {
	    	var gcd = calcultateGCD(vals[0],vals[1],1);
	    	var lcm = calcultateLCM(vals[0],vals[1],gcd);
	    	if(lcm > 2000000000)
		    	console.log("Invalid dataset: "+line+ ". LCM is "+lcm+" but must be <= 2,000,000,000");
	    	else 
	    		console.log(gcd+" "+lcm);
		}
	}
}

Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <queue>
#include <cstdlib>
#include <assert.h>

const int MAXN = 1e5 + 5;

using namespace std;

vector<int>graf[MAXN];
bool viz[MAXN];
int n,m,dp[MAXN];

int dfs(int nod){
    viz[nod] = true;
    for(int i = 0; i < graf[nod].size(); i++){
        int curent = graf[nod][i];
        if(!viz[curent])
            dfs(curent);
        dp[nod] = max(dp[nod],dp[curent] + 1);
    }
}

int main()
{
    cin>>n>>m;
    int aux = 1;
    for(int i = 1; i <= m; i++){
        int x,y;
        cin>>x>>y;
        graf[x].push_back(y);
    }
    int maxim = 0;
    for(int i = 1; i <= n; i++){
        if(!viz[i]){
            dfs(i);
            maxim = max(maxim,dp[i]);
        }
    }
    cout<<maxim;

    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    bool z = true;
    cin >> n;
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        if(x % 2 == 0){
            if( (x % 3 != 0) && (x % 5 != 0)){
                z = false;
                break;
            }
        }
    }
    if(z){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    
}

Measured memory_bytes: 256
A, B = map(int, input().split())

N_A = A / 0.08
N_B = B / 0.1
A_list = [int(N_A + i) for i in range(20) if A <= int(N_A+i)*0.08 < A+1]
B_list = [int(N_B + i) for i in range(20) if B <= int(N_B+i)*0.1 < B+1]

N_min = float('inf')
for i in B_list:
    if i in set(A_list) and i < N_min:
        N_min = i
if N_min == float('inf'):
    print(-1)
else:
    print(N_min)

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <regex>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;
int n,m;
int a[100005];
int main(int argc,char const* argv[])
{
  cin >> n >> m;
  for(int i=0;i<m;i++)
    {
      int l,r;
      cin >> l >> r;
      l--,r--;
      a[l]++,a[r]++;
    }
  for(int i=0;i<n;i++)
    {
      if(a[i]%2!=0)
	{
	  cout << "NO" << endl;
	  return 0;
	}
    }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	int N, R;
	cin >> N >> R;
	if(N>=10) cout << R << endl;
	else cout << R+100*(10-N) << endl;
	return 0;
}

Measured memory_bytes: 256
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
L[N] = -1
X = input()
M = X.count("1")+1
m = max(1,M-2)
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
        if M == 2:
            A = N
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)

Measured memory_bytes: 93828
/*氏名：保坂優介, 学籍番号：200441141
  概要：長方形を描く*/

#include<stdio.h>

int main(void)
{
    int i, j, H, W;     //変数の宣言

    scanf("%d %d", &H, &W);     //入力

    while (H != 0 && W != 0)        //0 0が入力されるまで繰り返す
    {
        for (i = 0; i < H; i++)     //H回繰り返す
        {
            for (j = 0; j < W; j++)     //W回繰り返す
            {
                printf("#");        //表示
            }
            printf("\n");       //改行
        }
        scanf("%d %d", &H, &W);
        printf("\n");

    }

    return 0;
}


Measured memory_bytes: 2032
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 21:49:38 2019

@author: over-
"""

N=int(input())
ans=False
for i in range(1,10):
    if N%i == 0 and N/i<10:
        ans=True
    
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

int n = read(), q = read();
int sum[N];
char s[N];

int main() {
     scanf("%s",s+1);
     for(int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1];
        if(s[i]=='C'&&s[i-1]=='A') {
            ++sum[i];
         }
     }
     while(q--){
        int l = read(), r = read();
        outn(sum[r]-sum[l]);
     }
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n;
    cin >> n;
    cout << n / 3 << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B, C;
ll ans;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	ans = (A * B) / 2;
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

int yukurido(int a, int b)
{
    int c = a % b;

    return c == 0 ? b : yukurido(b, c);
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    
    cout << (2 * N) / yukurido(2, N) << endl;

    return 0;
}

Measured memory_bytes: 256
L,A,B,M=map(int,input().split())
C=(L-1)*B+A
mod=M
X,s=0,A
now=A
data=[0]*19
ruiseki=[0]*19
Ami=(A-1)//B
Cmi=C//B
for i in range(19):
    now=10**i-1
    if now<A:
        ruiseki[i]=0
    elif now>=C:
        ruiseki[i]=L
    else:
        ruiseki[i]=(now-A)//B+1
def mul33(A,B):
    global mod
    res=[[0]*3 for i in range(3)]
    for i in range(3):
        for j in range(3):
            res[i][j]=sum([A[i][k]*B[k][j]%mod for k in range(3)])
    return res
def ruijou(vec,Cd):
    rui=dict()
    if Cd==0:
        return [[1,0,0],[0,1,0],[0,0,1]]
    now=vec
    ans=[[1,0,0],[0,1,0],[0,0,1]]
    Cds=bin(Cd)[2:][::-1]
    for i in range(len(Cds)):
        if Cds[i]=="1":
            ans=mul33(ans,now)
        now=mul33(now,now)
    return ans
def mul(X,s,Cd,d):
    global mod
    global B
    vec=[[pow(10,d,mod),0,0],[1,1,0],[0,B,1]]
    vec=ruijou(vec,Cd)
    Xc=X
    sc=s
    X=(Xc*vec[0][0]+sc*vec[1][0]+vec[2][0])%mod
    s=(Xc*vec[0][1]+sc*vec[1][1]+vec[2][1])%mod
    return X,s
for d in range(1,19):
    Cd=ruiseki[d]-ruiseki[d-1]
    X,s=mul(X,s,Cd,d)
print(X)

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> a(n);
    rep(i, n) a[i] = i + 1;

    map<vector<int>, int> mp;
    do
    {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248