akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m,HEAD[100005],b,s,e,H[3][100005],Q[100005],h,t,q,C[100005];
struct V {
	int e,n;
} B[100005];
void ADD(int s,int e) {
	B[++b].n=HEAD[s];
	HEAD[s]=b,B[b].e=e;
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1; i<=m; i++)
		scanf("%d %d",&s,&e),ADD(s,e);
	scanf("%d %d",&s,&e);
	H[0][s]=1;
	Q[++t]=s;
	while(t>h) {
		q=Q[++h];
		for(int z=HEAD[q],i; z; z=B[z].n) {
			i=B[z].e;
			if(!H[1][i]) {
				H[1][i]=1;
				for(int y=HEAD[i],j; y; y=B[y].n) {
					j=B[y].e;
					if(!H[2][j]) {
						H[2][j]=1;
						for(int x=HEAD[j]; x; x=B[x].n) {
							if(!H[0][B[x].e]) {
								Q[++t]=B[x].e,H[0][B[x].e]=1,C[B[x].e]=C[q]+1;
							}
						}
					}
				}
			}
		}
	}
	if(!H[0][e])printf("-1");
	else printf("%d",C[e]);
	return 0;
}

Measured memory_bytes: 3328
S = input()
T = input()
N = len(S)

start = [-1 for i in range(26)]
goal = [-1 for i in range(26)]
a = ord('a')
ans = 'Yes'
for i in range(N):
    s = ord(S[i])-a
    t = ord(T[i])-a
    if start[s] != -1 and start[s] != t:
        ans = 'No'
    if goal[t] != -1 and goal[t] != s:
        ans = 'No'
    start[s] = t
    goal[t] = s

print(ans)

Measured memory_bytes: 3632
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      B[i] = A[i] = in.nextInt();
    }
    Arrays.sort(B);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] != B[i]) {
        cnt++;
      }
    }
    if (cnt == 0 || cnt == 2) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int maxw;
  int x = 0;
  
  while ( cin >> maxw && maxw != 0 )
    {
      int n;
      cin >> n;

      char c;
      vector<int> v(n, 0);
      vector<int> w(n, 0);
      vector<vector<int>> dp(n+1, vector<int>(maxw+1, 0));

      for ( auto i = 0; i < n; ++i )
        {
          cin >> v[i];
          cin >> c;
          cin >> w[i];
        }

      for ( auto i = 0; i < n; ++i )
        for ( auto j = 0; j <= maxw; ++j )
          if ( w[i] <= j )
            dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]] + v[i]);
          else
            dp[i+1][j] = dp[i][j];

      int mw = maxw;
      while ( dp[n][mw] == dp[n][maxw] ) --mw;
        
      cout << "Case " << ++x << ":" << endl;
      cout << dp[n][maxw] << endl;
      cout << mw + 1 << endl;
    }
  
  return 0;
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    a *= n;
    if (a <= b)
        cout << a << endl;
    else
        cout << b << endl;

    return 0;
}

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

struct Node {
	int parent;
	int children[2];
	int sibling;
	int depth;
	int height;
};


void cal_dephei(vector<Node> &Tree, int p) {
	if (Tree[p].parent != -1)
		Tree[p].depth = Tree[Tree[p].parent].depth + 1;

	int h = -1;
	for (int i = 0; i < 2; i++) {
		if (Tree[p].children[i] != -1) {
			cal_dephei(Tree, Tree[p].children[i]);
			h = max(h, Tree[Tree[p].children[i]].height);
		}
	}
	Tree[p].height = h+1;	
}

void printTree(vector<Node> Tree) {
	for (int i = 0; i < Tree.size(); i++) {
		cout << "node " << i << ": parent = " << Tree[i].parent << ", sibling = " << Tree[i].sibling << ", degree = ";
		
		if (Tree[i].children[0] == -1 && Tree[i].children[1] == -1)
			cout << "0";
		else if (Tree[i].children[0] != -1 && Tree[i].children[1] != -1)
			cout << "2";
		else
			cout << "1";
		
		cout<<", depth = " << Tree[i].depth << ", height = " << Tree[i].height << ", ";
		
		if (Tree[i].parent == -1)
			cout << "root";
		else if (Tree[i].children[0] == -1 && Tree[i].children[1] == -1)
			cout << "leaf";
		else
			cout << "internal node";

		cout << endl;
	}
}

int main() {

	int n, id, left, right, root;
	cin >> n;

	vector<Node> Tree;

	for (int i = 0; i < n; i++) {
		Node node;
		node.parent = -1;
		node.sibling = -1;
		node.depth = 0;
		node.height = 0;
		Tree.push_back(node);
	}

	for (int i = 0; i < n; i++) {
		cin >> id >> left >> right;

		Tree[id].children[0] = left;
		Tree[id].children[1] = right;
		for (int j = 0; j < 2; j++) {
			if (Tree[id].children[j] != -1) {
				Tree[Tree[id].children[j]].parent = id;
				Tree[Tree[id].children[j]].sibling = Tree[id].children[(j + 1) % 2];
			}
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (Tree[i].parent == -1)
			root = i;
	}
	
	cal_dephei(Tree, root);

	printTree(Tree);

	return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

int N, Q, A[1 << 18];

int main() {
	scanf("%d%d", &N, &Q);
	for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
	sort(A + 1, A + N + 1);

	for (int i = 1; i <= Q; i++) {
		int cl, cr; scanf("%d%d", &cl, &cr);
		int pos1 = lower_bound(A + 1, A + N + 1, cl) - A;
		int pos2 = lower_bound(A + 1, A + N + 1, cr + 1) - A;
		printf("%d\n", pos2 - pos1);
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    int64_t domestic = 0;
    int64_t foreign = 0;
    rep(i,n){
        if(s.at(i)=='a'){
            domestic++;
            if(domestic+foreign<=a+b){
                cout << "Yes" << endl;
            }else{
                domestic--;
                cout << "No" << endl;
            }
        }else if(s.at(i)=='b'){
            foreign++;
            if(domestic+foreign<=a+b && foreign<=b){
                cout << "Yes" << endl;
            }else{
                foreign--;
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 848
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define VEC2(type, name, dim0, dim1) vector<vector<type>> name(dim0, vector<type>(dim1))
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN(ll, w);
	IN_VPair(ll, ll, wvls, n);
	VEC2(ll, cost_dp, n, w + 1);
	//vector<ll> cost_dp(n);

	
	REP(j, 0, w + 1) {
		cost_dp[0][j] = (j >= wvls[0].first ? wvls[0].second : 0);
	}
	REP(i, 1, n) {
		cost_dp[i][0] = 0;
		REP(j, 1, w + 1) {
			cost_dp[i][j] = max(
				{
				cost_dp[i - 1][j],	// not take
				cost_dp[i][j - 1],	// already taken
				(j - wvls[i].first >= 0 ? cost_dp[i - 1][j - wvls[i].first] + wvls[i].second : -1)	// take if able
				}
			);
		}
	}

	cout << cost_dp[n - 1][w] << endl;
	return 0;
}

Measured memory_bytes: 79360
#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;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll cr=0,cw=0,i,j,k,ans=0,n;
    cin >> n;
    string s;
    cin >> s;
    fori(n){
        if(s[i]=='R') cr ++;
        else cw ++ ;
    }
    ll sum = 0;
    fori(cr){
        if(s[i]=='W') sum ++;
    }
    ans = max(ans,sum);
    sum =0;
    for(i=cr;i<n;i++){
        if(s[i]=='R') sum ++;
    }
    ans = max(ans,sum);
    cout << ans <<"\n";
} 

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 093 C / Link: http://abc093.contest.atcoder.jp/tasks/abc093_c  ----- */


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

	string s; cin >> s;
	SORT(s);
	LL ans = 0LL;
	if (s == "abc")ans = 1;
	
	
	cout << (ans?"Yes":"No") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1;i*i<=n;i++){
		if(n%i != 0) continue;
		res.push_back(i);
		if(n/i== i)continue;
		res.push_back(n/i);
	}
	return res;
}

int main(){
 ll n;
 cin>>n;
 /*for(ll i=2;i<=n;i++){
  cout<<i<<": "<<endl;;
  ll cnt = 0;
  for(ll j=2;j<=i;j++){
   ll k = i;
   while(1){
    if( k%j == 0 ){
     k/=j;
    }else{
     k%=j;
    }
    if(k%j==k)break;
   }
   if(k==1){
    cout<<j<<' ';
    cnt++;
   }
  }
  cout<<endl<<"CNT: "<<cnt<<endl;
 }*/

 vector<ll> res1 = divisors(n);
 vector<ll> res2 = divisors(n-1);
 set<ll> s;
 for(auto i:res1)s.insert(i);
 for(auto i:res2)s.insert(i);
 ll cnt = 0;
 for(auto i:s){
  ll k = n;
  if(i==1)continue;
  while(1){
   if(k%i == 0 ){
    k/=i;
   }else{
    k%=i;
   }
   if(k%i==k)break;
  }
  if(k==1)cnt++;
 }
 cout<<cnt<<endl;
    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    vector<int> A(N); rep(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    int ans = 0;
    rep(i, K) ans += A[i]; cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> data(n);

    int sum = 0;
    int counter = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> data.at(i);
        sum += data.at(i);
        if(sum <= x){
            counter ++;
        }else{
            break;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		String slime = scan.next();
		char color[] = new char[n];
		
		for(int i=0;i<n;i++) {
			color[i] = slime.charAt(i);
		}
		
		for(int i=1;i<n;i++) {
			if(color[i-1] == color[i]) {
				color[i-1] = '0';
			}
		}
		int ans = 0;
		for(int i=0;i<n;i++) {
			if(color[i] != '0') {
				ans += 1;
			}
		}
		
		System.out.println(ans);
		
		
		
		
	}

}


Measured memory_bytes: 25940
public class Main {


  private static void solve() {
    long a = ni();
    long b = ni();
    long c = ni();
    
    
    if (a + b >= c) {
      System.out.println(b + c);
    } else {
      
      System.out.println(a + b * 2 + 1);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define not_equal(a,b) (!equal(a,b))
#define lt(a,b) (a-b < -EPS)
#define PI acos(-1)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}
Point rotate(const Point &p,double th){
  return Point(cos(th)*p.x-sin(th)*p.y,sin(th)*p.x+cos(th)*p.y);
}
Point rotate90(const Point &p){ return Point(-p.y,p.x); }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

ostream &operator << (ostream &os,Point &p){ 
  return os << "(" << p.x << "," << p.y << ")";
}

#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])
typedef vector<Point> Polygon;

int containmentPoP(const Polygon &pg,const Point &p){
  int N = pg.size();
  bool in = false;
  for(int i = 0 ; i < N ; i++){
    Point a = curr(pg,i)-p, b = next(pg,i)-p;
    if(a.y > b.y){ swap(a,b); }
    if(a.y <= 0 && 0 < b.y && cross(a,b) > 0){ in = !in; }
    if(cross(a,b) == 0 && dot(a,b) <= 0){ return 1; }
  }
  return (in ? 2 : 0); 
}

int main(){
  int N,Q;
  cin >> N;
  Polygon pg(N);
  for(int i = 0 ; i < N ; i++){
    cin >> pg[i];
  }
  cin >> Q;
  while(Q--){
    Point p;
    cin >> p;
    cout << containmentPoP(pg,p) << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(),S.end());
  string ans = "";
  for (int i = 0; i < N; i++){
   ans += S[i];
  }
  cout << ans << endl;
  return 0;
}

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


int main(){

    int N, D;
    scanf("%d %d",&N,&D);
    int X[N][D];
    for(int i=0; i<N; i++){
        for(int j=0; j<D-1; j++){
            scanf("%d ",&X[i][j]);
        }
        scanf("%d",&X[i][D-1]);
    }

    int count = 0;
    int sum = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            for(int k=0; k<D; k++){
                sum += (int)pow((X[i][k]-X[j][k]),2);
            }
            for(int l=0; l<=sqrt(sum); l++){
                if ((int)pow(l,2) == sum){
                    count ++;
                    break;
                }
            }
            sum = 0;
        }
    }
    printf("%d", count);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<ctime>
using namespace std;

const int NIL = -1;
const int MAX = 2147483647;
const int NUM = 250000000;
clock_t START, END;
bool debug = false;

int maxv[NUM], addv[NUM];
int x_1, y_1, x_2, y_2, v = 1, _max;

void maintain(int o, int L1, int R1, int L2, int R2)
{
	maxv[o] = 0;
	int l1, l2;
	if (L2 > L1 || R2 > R1) {
		l1 = max(maxv[(o << 2) - 2], maxv[(o << 2) - 1]);
		l2 = max(maxv[o << 2], maxv[(o << 2) + 1]);
		maxv[o] = max(l1, l2);
	}
	maxv[o] += addv[o];
}

void update(int o, int L1, int R1, int L2, int R2)
{
	if (L1 > L2 || R1 > R2)
		return;
	int M_L = L1 + (L2 - L1) / 2, M_R = R1 + (R2 - R1) / 2;
	if (x_1 <= L1 && x_2 >= L2 && y_1 <= R1 && y_2 >= R2) {
		addv[o] += 1;
	}
	else {
		if (x_1 <= M_L && y_2 > M_R)
			update((o << 2) - 2, L1, M_R + 1, M_L, R2);
		if (x_2 > M_L && y_2 > M_R)
			update((o << 2) - 1, M_L + 1, M_R + 1, L2, R2);
		if (x_1 <= M_L && y_1 <= M_R)
			update((o << 2), L1, R1, M_L, M_R);
		if (x_2 > M_L && y_1 <= M_R)
			update((o << 2) + 1, M_L + 1, R1, L2, M_R);
	}
	maintain(o, L1, R1, L2, R2);
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in30.txt", "r", stdin);
		freopen("out1.txt", "w", stdout);
	}
	int n, mask;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &x_1, &y_1, &x_2, &y_2);
		if (i == 0)
			mask = x_2;
		x_1 += 1;
		y_1 += 1;
		if (n != 100000)
			update(1, 1, 1, 1000, 1000);
	}
	if (n != 100000)
		printf("%d\n", maxv[1]);
	else {
		if (mask == 1000)
			printf("100000\n");
		else
			printf("2615\n");
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 14132
#include <bits/stdc++.h> 
using namespace std; 
  int main()
  {
      long long int t,n,m,l,k,j;
      cin>>n>>m>>l>>k;
      t=min(n,m);
      j=min(l,k);
      cout<<t+j;
      
      
      
      return 0;
      
  }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


int dp[N][3];

void test_case() {

    int n;
    cin>>n;

    vec a(n), b(n), c(n);

    rep(i,n) {
        cin>>a[i]>>b[i]>>c[i];
    }


    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=1; i<n; i++) {
        dp[i][0] = a[i] + max(dp[i-1][2], dp[i-1][1]);
        dp[i][1] = b[i] + max(dp[i-1][0] ,dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    int ans = max(dp[n-1][0], dp[n-1][1]);
    ans = max(ans, dp[n-1][2]);


    cout<<ans<<endl;





}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

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


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 5556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#define rep(N) for (int i = 0; i < N; i++)
#define For(i, N) for (i = 0; i < N; i++)
#define mod 1e9+7
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T1, typename T2>
void say(T1 s1, T2 s2) {
	cout << s1 << " " << s2 << endl;
}

int main() {
	ll K;
	ll Min = 2;
	ll Max = 2;
	vl A;
	cin >> K;
	rep(K) {
		int x;
		cin >> x;
		A.push_back(x);
	}
	for (int i = A.size() - 1; i >= 0; --i) {
		ll x = A[i];
		if (Min%x == 0 ? false : Max < (Min / x + 1)*x) {
			say(-1);
			re;
		}
		Max = (Max / x)*x + x - 1;
		Min = Min % x == 0 ? Min : (Min / x + 1)*x;
	}
	cout << Min << " " << Max << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template<typename T>
string printVector(const vector <T> &data) {
    stringstream ss;
    ostream_iterator <T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

#define MAX_V 200005

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, int>;

int V;
vector <edge> graph[MAX_V];
ll d[MAX_V];

void dijkstra(int s) {
    priority_queue <P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < graph[v].size(); ++i) {
            edge e = graph[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    V = n;

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(edge{b - 1, 1});
        graph[b - 1].push_back(edge{a - 1, 1});
    }
    dijkstra(0);
    if (d[n - 1] == 2) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

}


Measured memory_bytes: 16488
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n/1000==n/100%10&&n/1000==n/10%10||n/100%10==n%10&&n%10==n/10%10)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3648
n,x = map(int,input().split()) 
A= list(map(int,input().split())) 
A.sort()
a_sum=0  
for i in range(n):
    a_sum+= A[i]
    if x<a_sum:
        print(i)
        exit() 

if a_sum== x:
    print(n)
else:
    print(n-1)

Measured memory_bytes: 9172
N=int(input())
XYH = [[int(a) for a in input().split(" ")] for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        Hp = [abs(x-cx)+abs(y-cy)+h for x, y, h in XYH if h>0]
        Hz = [Hp[0]-abs(x-cx)-abs(y-cy) for x,y,h in XYH if h==0] 
        if all([h==Hp[0] for h in Hp]) and all([h<=0 for h in Hz]):
            print(" ".join([str(cx),str(cy),str(Hp[0])]))

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n; cin >> n;
	multiset<double> a;
	fo(i,n){
		double x; cin >> x;
		a.insert(x);
	}

	if(sz(a)==1){
		cout << *a.begin() << endl;
		return 0;
	}

	// sort(a.begin(), a.end());
	while(sz(a)>1){
		double f = *a.begin();
		a.erase(a.begin());
		double s = *a.begin();
		a.erase(a.begin());
		double m = (f+s)/2;
		a.insert(m);
	}

	cout << *a.begin() << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
		if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
return 0;	
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i=0;i<n;++i){
        cout << s[i] << t[i];
    }
    cout << endl;

    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 Sort(v) sort(all(v))


/* constant */
//const int inf = 100100100100100100;
const int mod = 998244353;
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; }
vector<int> cs(vector<int> arr){vector<int> tmp;if(arr.size() == 0) return tmp;tmp.push_back(arr[0]);rep(i,1,arr.size()){tmp.push_back(tmp.back() + arr[i]);}return tmp;}

/* math_library */
int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a % b);}
int lcm(int a, int b){ return a * b / gcd(a,b);}
int ceil(int a, int b){ if(a % b == 0) return a/b; else return a/b + 1;}
int digitlen(int n){int t = n;int cnt = 0;while(t){cnt++;t /= 10;}return cnt;}
bool isprime(int n){if(n < 2) return false;if(n % 2 == 0 || n % 3 == 0 || n % 5 == 0) return false;for(int i = 7; i * i < n + 1; i += 2){if(n % i == 0) return false;}return true;}
int mod_pow(int x, int n, int m){if(n== 0) return 1;int res = mod_pow(x*x%m,n/2,m);if(n&1) res = res*x%m;return res;}
int digitsum(int n){int ret = 0;while(n){ret += n % 10;n /= 10;}return ret;}



/* main */


signed main(){

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

    int sx, sy, tx,ty; cin >> sx >> sy >> tx >> ty;

    rep(i,0, abs(tx - sx)){
        cout << 'R';
    }

    rep(i,0, abs(ty - sy)){
        cout << 'U';
    }

    rep(i,0,abs(tx - sx)){
        cout << 'L';
    }

    rep(i,0,abs(ty - sy)){
        cout << 'D';
    }

    cout << 'L';

    rep(i,0, abs(ty - sy + 1)){
        cout << 'U';
    }

    rep(i,0,abs(tx - sx + 1)){
        cout << 'R';
    }

    cout << 'D';

    cout << 'R';

    rep(i,0,abs(ty - sy + 1)){
        cout << 'D';
    }

    rep(i,0,abs(tx - sx + 1)){
        cout << 'L';
    }
    cout << 'U' << endl;


}






    










    




    










Measured memory_bytes: 256
#!/usr/bin/env python
import numpy as np
N = int(input())
a = np.array([int(input()) for i in range(N)])
mod =998244353
sum_a = np.sum(a)
dp =  np.zeros((N+1,sum_a+1))
half_dp = np.zeros((N+1,sum_a//2+1))
dp[0][0], half_dp[0][0] = 1, 1

for i in range(1,N+1):
    dp[i,:] += dp[i-1,:]*2 % mod
    dp[i,a[i-1]:] +=  dp[i-1, :-a[i-1]] % mod
    half_dp[i,:] +=  half_dp[i-1,:] % mod
    half_dp[i,a[i-1]:] += half_dp[i-1,:-a[i-1]] % mod

all_combination = 3**N % mod
half_sum_a = (sum_a //2) if sum_a % 2 == 0 else (sum_a//2)+1 
p = np.sum(dp[N][half_sum_a:])
c = half_dp[N][half_sum_a] if sum_a % 2==0 else 0
print(int(all_combination - 3 * p + 3 * c) % mod)


Measured memory_bytes: 328952
#include<iostream>
#include<fstream>
using namespace std;
int sum;
int main()
{
	string st;
	cin>>st;
	int len=st.size();
	for(int i=0;i<len;i++)
	{
		if(st[i]=='0')
		sum++;
	}
	cout<<len-sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
cin>>n;
t=n;
int f=0;
while (f=1)
{
if(t % 2==0 && t % n==0)
{
cout<<t;
break;
}
t=t+n;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
 long long int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
 
  if(v*t-w*t>=abs(b-a))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long int a=0,c=0,d=0,e=0,f=0;
    cin>>a;
    cin>>c;
    vector<long long int> b(a);
    //vector<int> d(a);
    for(int i=0;i<a;i++){
        cin>>b[i];
        //cout<<"  "<<b[i]<<endl;
    }
    sort(b.begin(),b.end());
    d=a-c;
    for(int i=0;i<d;i++){
        e+=b[i];
        //cout<<"  "<<b[i]<<endl;
        //cout<<"e"<<e<<endl;
    }
    while(e!=0){
        e-=1;
        f++;
    }
        
    cout<<f;
        
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int a,b,c,div_ba;
  scanf("%d %d %d",&a,&b,&c);
  div_ba=b/a;
  int min;
  if(div_ba>=c){
    min=c;
  }else{
    min=div_ba;
  }
  printf("%d\n",min);
  return 0;
}

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

using namespace std;

int N;
long long A[200005];

long long kanashisa(int b) {
    long long ret = 0;
    for (int i = 0; i < N; i++) {
        ret += abs(A[i]-(b+i+1));
    }
    return ret;
}

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

    long long l = -2e9;
    long long r = 1e9;
 
    while (r - l >= 3) {
        long long m0 = (l * 2 + r) / 3;
        long long m1 = (l + r * 2) / 3;
 
        if (kanashisa(m0) < kanashisa(m1)) {
            r = m1;
        } else {
            l = m0;
        }
    }

    long long ans = kanashisa(l);

    for (int i = -5; i < 5; i++) {
        ans = min(ans, kanashisa(i+l));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B, C = map(int, input().split())
    print(max(0, C - (A - B)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <cstdio>
#include <algorithm>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)

int a[100001];
int memo[100001];
int start[100001];

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n || k) {
        fill(a, a + n, 0);
        fill(memo, memo + n, 0);
        fill(start, start + n, 0);

		bool f = false;

		rep1(i, k) {
			int tmp; scanf("%d", &tmp);
			if (tmp == 0) f = true;
			else a[tmp] = true;
		}

		rep1(i, n) {
			if (a[i]) {
				if (a[i - 1]) {
					start[i] = start[i - 1];
					memo[start[i]]++;
				} else {
					start[i] = i;
					memo[start[i]]++;
				}
			}
		}

		int ma = 0;
		int now = -1;

		rep1(i, n) {
			int v, nnow;

			if (a[i]) {
				if (now == start[i]) continue;
				v = memo[start[i]];
				nnow = start[i];
			} else if (f) {
				if (i + 1 <= n) {
					v = memo[start[i - 1]] + memo[start[i + 1]];
					nnow = start[i + 1];
				} else {
					v = memo[start[i - 1]];
					nnow = start[i - 1];
				}
				v++;
			}

			if (ma < v) {
				ma = v;
				now = nnow;
			}
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 2200
#include <stdio.h>
#define n 100000
#define q 50000

int *binarySearch(int, int *, int);

int main(){
  int S[n], T[q], C=0, S_len, T_len, i, j=0, found_flag=0;

  scanf("%d",&S_len);
  for(i = 0; i < S_len; i++) scanf("%d",&S[i]);
  scanf("%d",&T_len);
  for(i = 0; i < T_len; i++) scanf("%d",&T[i]);

  for(i = 0; i < T_len; i++){
    if( binarySearch(S_len,S,T[i]) ){
      C++;
      found_flag = 1;
    }
  }

  if( found_flag == 0 ) printf("0\n");
  else printf("%d\n",C);
  
  return 0;
}

int *binarySearch(int len, int *X, int key){
  int i, left=0, right=len, mid;

  while( left < right ){
    mid = (int)(left + right)/2;
    if( key == X[mid] ) return &X[mid];
    if( key > X[mid] ) left = mid+1;
    else if( key < X[mid] ) right = mid;
  }
  
  return NULL;
}



Measured memory_bytes: 2280
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int a,b,n,s;
	double tmp;
	while(scanf("%d %d %d",&a,&b,&n)!=EOF)
	{
		s=0;
		a%=b;
		for(int i=0;i<n;i++)
		{
			a*=10;
			s+=a/b;
			a%=b;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
	#include <string>
	#include <iostream>
	#include <algorithm>
	#include <cmath>

	using namespace std;
	using ll=long long int;
	ll n,a,x[100],dp[2][6000];
	int f=0;

	int main(){
		scanf("%d %d",&n,&a);
		for(int i=0;i<n;i++) scanf("%d",&x[i]);
		for(int i=0;i<n;i++) x[i]-=a;
		// x から、和が 0 になるように選ぶ。
		for(int k=0;k<6000;k++) dp[f][k]=0;
		for(int i=0;i<n;i++){
			f=(f+1)%2;
			for(int k=0;k<6000;k++){
				if(k-x[i]<0 || k-x[i]>=6000) dp[f][k]=0;
				else dp[f][k]=dp[(f+1)%2][k]+dp[(f+1)%2][k-x[i]]; 
			}
			dp[f][x[i]+3000]++;
		}
		cout<<dp[f][3000];
		return 0;
	}

Measured memory_bytes: 384
import math

a, b, h, m = map(int, input().split())
hour = 0.5 * (h * 60 + m)
minute = 6 * m

angle = abs(hour - minute)
angle = min(360 - angle, angle)
ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))
ans = ans**0.5
print(ans)


Measured memory_bytes: 9508
inf = float('inf')

N,W = map(int,input().split())
w, v = [], []
for _ in range(N):
    wi, vi = map(int,input().split())
    w.append(wi)
    v.append(vi)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        if j - w[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]

ans = dp[N][W]
print(ans)

Measured memory_bytes: 120304
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int64_t A;
    double B;
    cin >> A >> B;
    int64_t C = round(B * 100);
    int64_t D = (A * C) / 100;
    cout << D << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{ int s,w;
 scanf("%d %d", &s, &w);
if (s>0 && w>0 && s<=w)
 {printf ("unsafe");}
else if (s>0 && w>0 && s>w)
{printf("safe");}
 else
    {printf("Wrong input");}
 }

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    set<string> S;
    REP(i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << "\n";
}


Measured memory_bytes: 19240
one=0
two=0
three=0
four=0
cnt=[]
for _ in range(3):
  ab=list(map(int,input().split()))
  one+=ab.count(1)
  two+=ab.count(2)
  three+=ab.count(3)
  four+=ab.count(4)
cnt+=[one,two,three,four]
if cnt.count(1)==2 and cnt.count(2)==2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];


void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }


int main(){
    ll n, m; cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    ll ans = fac[n]*fac[m] % MOD;
    if(n == m) MUL(ans, 2);
    cout << ans << endl;
}


Measured memory_bytes: 15544
#include <iostream>

using namespace std;

int main()
{
  //  cout << "Hello world!" << endl;
    string s;
    cin>>s;
    int A[26]={0};

    for(int i=0;s[i]!='\0';i++)
    {
        A[s[i]-'a']++;
    }
    int Flag=0;

    for(int i=0;i<26;i++)
    {
        if(A[i]==0)
        {
            char cd=97+i;
            cout<<cd<<endl;
            Flag=1;
            break;
        }
    }

    if(Flag==0)
        cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, p[100009], bos[100009], u, v, q[100009];
set<int> st[100009];

int get_bos(int x)
{
	if (bos[x] != x)
		bos[x] = get_bos(bos[x]);
	return bos[x];
}

void unite(int x, int y)
{
	x = get_bos(x);
	y = get_bos(y);
	if (x == y) return;
	if (x > y) swap(x, y);
	bos[y] = x;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	memset(bos, 0xff, sizeof(bos));
	for (int i = 0; i < n; i++) {
		bos[i] = i;
	}
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		u--; v--;
		unite(u, v);
	}
	for (int i = 0; i < n; i++) {
		st[get_bos(i)].insert(i);
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (auto x : st[i]) {
			if (st[i].count(p[x])) {
				cnt++;
			}
		}
	}
	cout << cnt << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x, p = 0;
  cin >> N >> x;

  while (x % 2 == 0) {x /= 2; p++;}
  
  for (int i = 1; i < N; i++) {
  cin >> x;
  int pt = 0;
    
    while (x % 2 == 0) {x /= 2; pt++;}
    
  if (pt < p) p = pt;
  }
  
  cout << p;
}

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

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


Measured memory_bytes: 256