akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long n, m;
    vector<vector<vector<long long>>> edges(100000, vector<vector<long long>>());
    
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        long long l, r, d;
        cin >> l >> r >> d;
        
        edges[l-1].push_back(vector<long long>{r-1, d});
        edges[r-1].push_back(vector<long long>{l-1, -d});
    }
    
    long long dist[100000];
    for(int i = 0; i < n; i++)
        dist[i] = LLONG_MAX;
    
    for(int i = 0; i < n; i++){
        if(dist[i] != LLONG_MAX)
            continue;
        deque<vector<long long>> q;
        q.push_back(vector<long long>{i, 0});
        dist[i] = 0;
        while(q.size() > 0){
            vector<long long> front = q.front();
            q.pop_front();
            
            for(auto e:edges[front[0]]){
                if(dist[e[0]] != LLONG_MAX){
                    if(dist[e[0]] != front[1]+e[1]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
                else{
                    vector<long long> temp{e[0], front[1]+e[1]};
                    q.push_back(temp);
                    dist[e[0]] = front[1] + e[1];
                }
            }
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> P(N);
   auto __assert = [&](bool z) {
      if (!z) {
         cout << "No\n";
         exit(0);
      }
   };
   for (int i = 0; i < N; ++i) {
      cin >> P[i];
      --P[i];
   }
   for (int i = 0; i < N; ++i) {
      __assert((P[i] & 1) == (i & 1));
   }
   int prv = 0;
   int pref = -1;
   for (int i = 0; i < N; ++i) {
      pref = max(pref, P[i]);
      if (pref == i) {
         int nxt = i;
         if (prv < nxt) {
            for (int j = prv + 1; j < nxt; j += 2) {
               __assert(P[j] == j);
            }
            int lastForw = -1;
            int lastBackw = -1;
            for (int j = prv; j <= nxt; j += 2) {
               if (P[j] > j) {
                  __assert(P[j] > lastForw);
                  lastForw = P[j];
               } else {
                  __assert(P[j] > lastBackw);
                  lastBackw = P[j];
               }
            }
         }
         prv = nxt + 1;
      }
   }
   cout << "Yes\n";
   return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;
using ll = long long;

void Main() {
	int a, b; cin >> a >> b;
	int tmp = a - 2 * b;
	cout << (tmp < 0 ? 0 : tmp) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

int main()
{
    int x[4];
    int ans;
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
    }

    for (int i = 0; i < 5; i++)
    {
        if (x[i] == 0)
        {
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int [N];
		int[] t = new int [N];
		int p = 1001;
		for (int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if (t[i] <= T && c[i] < p) {
				p = c[i];
			}
		}
		if (p == 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 22868
#include <stdio.h>
int main(void){
    int a, b, c, x, i;
    scanf("%d %d %d", &a, &b, &c);
    for(i = a, x = 0; i != b+1; i++){
        if(c % i == 0){
            x++;
        }
    }
    printf("%d\n", x);
    return 0;
}



Measured memory_bytes: 2100
n = gets.chomp.to_i
b = gets.chomp.split.map(&:to_i)

a = Array.new(n, 0)

a[0] = b[0]
1.upto(n-2) do |i|
  a[i] = b[i-1..i].min
end
a[n - 1] = b[n - 2]
p a.inject(:+)


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 17 14:00:57 2020
@author: Ahmad Hamadneh
"""
x=int(input())
m=input().split()

dp=[]
dp.append(0)
for i in range(1,x):
    if i == 1 :
        dp.append(abs(int(m[i])-int(m[i-1])))
    else :
        dp.append(min(abs(dp[i-1]+abs(int(m[i-1])-int(m[i]))),dp[i-2]+abs(int(m[i-2])-int(m[i]))))
print(dp[x-1])


Measured memory_bytes: 13912
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

bool alpha[26];

int main()
{
    string s;
    cin >> s;
    for(auto itr = s.begin(); itr < s.end(); ++itr){
        alpha[*itr - 'a'] = true;
    }
    bool notFound = true;
    for(int i = 0; i < 26; ++i){
        if(alpha[i] == false) {
            char c = i + 'a';
            cout << c << endl;
            return 0;
        }
    }
    if(notFound)
        cout << "None" << endl;
    return 0;
}

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

int main() {
	int x, a, b,c;

	cin >> a >> b;

	x = (a+b)/2 ;

	c = (a+b)%2;

	if (c==1) {
		x = x + 1;
	}

	cout << x << endl;



	return 0;
}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n;
    cin>>n;

    int ans = 0;
    f1(i,1,n)
    {
        int k = n/i;
        // if(n%i == 0) ans -= 1;
        if(k >= i)
        {
            ans += (k - (i-1))*2;
            if(n%i == 0) ans -= 2;
            if(i*i < n) ans--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3648
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String a = st.nextToken();
         String b = infile.readLine(); int res = 0;
         for(int i=0; i < a.length(); i++)
            if(a.charAt(i) != b.charAt(i))
               res++;
         System.out.println(res);
      }
   }

Measured memory_bytes: 37288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define READ      freopen("input.txt", "r", stdin);
#define WRITE     freopen("output.txt", "w", stdout);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
const ll MAX = 1e6 + 5;
const ll INF = 1e18L + 5;

ll dp[MAX];


int main() {

	_cin
	// READ
	// WRITE
	ll n, k;
	cin >> n >> k;
	ll a[k];
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, k+1) {
		if (dp[i] == 0) {
			rep(j, 0, n) {
				dp[i + a[j]] = 1;
			}

		}
	}

    if(dp[k]==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;


}

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


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int max_count = 0;
    for (int i = 0; i < n; i++) {
        set<char> x(s.begin(), s.begin()+i+1);
        set<char> y(s.begin()+i+1, s.end());

        int _count = 0;
        string kinds = "";
        for (char c : x) {
            if (count(y.begin(), y.end(), c) > 0 && count(kinds.begin(), kinds.end(), c) == 0) {
                _count++;
                kinds.push_back(c);
            }
        }
        if (max_count < _count) max_count = _count;
    }
    cout << max_count << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [a, b, c, k]
  | a >= k = k
  | a + b >= k = a
  | otherwise = 2 * a + b - k


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

int main(){
	double n;
	cin >> n;
	int mi=(n+1.07)/1.08;double ma=(n+1)/1.08;
  	if(mi<ma){
      cout << mi << endl;
    }else{
      cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
// 平方数に近い値から探索する.

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll N; cin >> N;
  ll t;
  for(ll i=sqrt(N);i>=1;i--){
    if(N%i==0){
      t = N/i; // tはAとBのうち大きい方
      break;
    }
  }
  int ans = 0;
  while(t!=0){
    t = t/10;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

typedef long long ll;

const int Maxn = 100010;

ll a[Maxn], minv[Maxn], maxv[Maxn];


int main() {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) cin >> a[i];

    if (a[k - 1] != 2) {
        cout << -1 << endl;
        return 0;
    }

    minv[k - 1] = 2;
    maxv[k - 1] = 3;

    for (int i = k - 1; i > 0; --i) {
        ll l = (minv[i] + a[i - 1] - 1) / a[i - 1];
        minv[i - 1] = l * a[i - 1];
        l = maxv[i] / a[i - 1] + 1;
        maxv[i - 1] = a[i - 1] * l - 1;

        if (minv[i - 1] > maxv[i - 1]){
            cout << -1 << endl;
            return 0;
        }
    }


    cout << minv[0] << " " << maxv[0] << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int goal;
	int n, i;
	int sum;
	int start, end;

	while (scanf("%d", &goal), goal){
		scanf("%d", &n);
		for (i = sum = 0; i < n; i++){
			scanf("%d %d", &start, &end);
			sum += end - start;
		}

		if (goal <= sum){
			puts("OK");
		}
		else {
			printf("%d\n", goal - sum);
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
using P = pair<int64_t, int64_t>;

int64_t MOD = 1e9+7;

//繰り返し二乗法
int64_t powmod(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}

int main(){
  int64_t N;
  cin >> N;
  map<P,int64_t> mp;
  int64_t zero_zero = 0;
  int64_t a_zero = 0;
  int64_t b_zero = 0;
  for(int i=0; i<N; i++){
    int64_t a, b;
    cin >> a >> b;
    if(a == 0 || b == 0){
      if(a == 0 && b == 0){
        zero_zero++;
      }
      else if(a == 0){
        a_zero++;
      }
      else{
        b_zero++;
      }
      continue;
    }
    int64_t c = gcd(a,b);
    a /= c;
    b /= c;
    if(b < 0){
      a *= -1;
      b *= -1;
    }
    P p = {a,b};
    if(mp.count(p)){
      mp[p]++;
    }
    else{
      mp[p] = 1;
    }
  }

  if(a_zero > 0){
    P r = {0,1};
    mp[r] = a_zero;
  }
  if(b_zero > 0){
    P r = {-1,0};
    mp[r] = b_zero;
  }

  
  int64_t ans = 1;
  set<P> S;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    P p = itr->first;
    int64_t a = p.first;
    int64_t b = p.second;
    if(a < 0){
      P q = {b,a*-1};
      if(mp.count(q)){
        ans *= (powmod(2,mp[p]) - 1 + powmod(2,mp[q]) -1) + 1;
        S.insert(q);
      }
      else{
        ans *= powmod(2,mp[p]);
      }
    }
    else{
      if(S.count(p)){
        continue;
      }
      else{
        ans *= powmod(2,mp[p]);
      }
    }
    ans %= MOD;
  }
  cout << (ans - 1 + zero_zero + MOD) % MOD << endl;
}

Measured memory_bytes: 15880
r,g,b,n=map(int,input().split())
ans=0
for i in range(1+n//r):
    for j in range(1+(n-r*i)//g):
        if (n-i*r-g*j)%b==0 and (n-i*r-g*j)//b>=0:
            ans+=1
print(ans)

Measured memory_bytes: 66880
import java.util.*;
import java.io.*;
 
public class Main{
  public static void main(String[]args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] S = br.readLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[][] val = new int[M][3];
    for(int i = 0; i < M; i++){
      String[] T = br.readLine().split(" ");
      val[i][0] = Integer.parseInt(T[0]);
      val[i][1] = Integer.parseInt(T[1]);
      val[i][2] = i;
    }
    Arrays.sort(val, (a, b) -> Integer.compare(a[1], b[1]));
    
    String[] ans = new String[M];
    int[] count = new int[N+1];
    for(int i = 0; i < M; i++){
      int a = val[i][0];
      count[a]++;
      ans[val[i][2]] = String.format("%06d%06d", a, count[a]);
    }
    
    for(int i = 0; i < M; i++){
     System.out.println(ans[i]); 
    }
  }
}


Measured memory_bytes: 121284
#include<bits/stdc++.h>
using namespace std;
bool check(string s) {
  int len = s.length();
  bool result = true;
  for(int i = 0;i <len/2;i++){
  	if(s.substr(i,1) != s.substr(len-i - 1,1)){
    	result = false;
    }
  }
  return result;
}

int main(){
  string S,b,c;
  int slen;
  cin >> S;
  slen = S.length();
  b = S.substr(0,((slen - 1)/2));
  c = S.substr((((slen + 3)/2) - 1) ,(slen - 1));
  if(check(S) && check(b) && check(c)){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a = int(input())
b = list(input())
frag = 0
parks = [list("SS"),list("SW"),list("WS"),list("WW")]
for park in parks:
    for i in range(len(b)-2):
        if b[i+1] == "o":
            if park[i]=="S" and park[i+1]=="S":
                park.append("S")
            elif park[i]=="S" and park[i+1]=="W":
                park.append("W")
            elif park[i]=="W" and park[i+1]=="S":
                park.append("W")
            elif park[i]=="W" and park[i+1]=="W":
                park.append("S")
        elif b[i+1] == "x":
            if park[i]=="S" and park[i+1]=="S":
                park.append("W")
            elif park[i]=="S" and park[i+1]=="W":
                park.append("S")
            elif park[i]=="W" and park[i+1]=="S":
                park.append("S")
            elif park[i]=="W" and park[i+1]=="W":
                park.append("W")
    
    frag2 = 0
    if b[0]=="o":
        if park[0] == "S":
            if park[-1]==park[1]:
                frag2 = 1 
        if park[0] == "W":
            if park[-1]!=park[1]:
                frag2 = 1
    if b[0]=="x":
        if park[0] == "S":
            if park[-1]!=park[1]:
                frag2 = 1
        if park[0] == "W":
            if park[-1]==park[1]:
                frag2 = 1
                
    if frag2 == 1:
        if b[-1]=="o":
            if park[-1] == "S":
                if park[0]==park[-2]:
                    print (''.join(park))
                    frag = 1
                    break
            if park[-1] == "W":
                if park[0]!=park[-2]:
                    print (''.join(park))
                    frag = 1
                    break
        if b[-1]=="x":
            if park[-1] == "S":
                if park[0]!=park[-2]:
                    print (''.join(park))
                    frag = 1
                    break
            if park[-1] == "W":
                if park[0]==park[-2]:
                    print (''.join(park))
                    frag = 1
                    break
if frag == 0:
    print(-1)
        

Measured memory_bytes: 7384
#include <stdio.h>
int sosu(int a){
  int j;
  for(j=2;j*j<=a;j++){
    if(a%j==0) return 0;
  }
  return 1;
}
main(){
  int n,i;
  while(scanf("%d",&n) !=EOF){
    int np=0,nn=0,jud;
    for(i=n-1;i>0;i--){
      if(sosu(i)==1){
	nn=i;
	break;
      }
    }
    i=n+1;
    while(1){
      if(sosu(i)==1){
	np=i;
	break;
      }
      i++;
    }
    printf("%d %d\n",nn,np);

  }    
  return 0; 
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif


int main()
{
	
	long long n,x,id,m,an=0;
	cin>>n;
	long long a[n+2];
	for(int i=1;i<=n;i++){cin>>a[i];an+=a[i];}
	cin>>m;
	while(m--)
	{cin>>id>>x;
		cout<<an-a[id]+x<<endl;
		
		
	}
	
}



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

ll n,a,b;

void input(){
    cin>>n>>a>>b;
}
void src(){
    input();
    if((a-b)%2==0){cout<<(b-a)/2;return;}
    if((n-a+n-b)<=(a-1+b-1)){
        cout<<((n-a)+(n-b)+1)/2;
    }else{
        cout<<((a-1)+(b-1)+1)/2;
    }
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeMap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut map = BTreeMap::new();
    for &a in a.iter() {
        *map.entry(a).or_insert(0) += 1;
    }

    let mut keys = map.keys().map(|key| *key).collect::<Vec<_>>();
    keys.sort();
    let n = keys.len();
    let max = keys[n - 1];
    let max_count = *map.get(&max).unwrap();

    for a in a.into_iter() {
        if max_count > 1 {
            println!("{}", max);
        } else if a == max {
            println!("{}", keys[n - 2]);
        } else {
            println!("{}", max);
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
    int N;
    char Y = 'Y';
    char S;
    cin >> N;
    while(true){
        cin >> S;
        if(S == Y){
            cout << "Four" << endl;
            break;
        }
        N--;
        if(N==0){
            cout << "Three" << endl;
            break;
        }
    }
}


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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

template <class T>
using P = pair<T, T>;

const int MAX_W = 100010;
long long dp1[MAX_W];
long long dp2[MAX_W];

int main() {
    int N, W;
    cin >> N >> W;
    V<int> w(N), v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    memset(dp1, -1, sizeof(dp1));
    memset(dp2, -1, sizeof(dp2));
    long long *prev = dp1, *nxt = dp2;

    prev[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            nxt[j] = prev[j];
        }
        for (int j = 0; j <= W; ++j) {
            if (prev[j] != -1 && j + w[i] <= W) {
                nxt[j + w[i]] = max(nxt[j + w[i]], prev[j] + v[i]);
            }
        }
        swap(prev, nxt);
    }

    cout << *max_element(prev, prev + W + 1) << endl;
    return 0;
}

Measured memory_bytes: 5116
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
using namespace std; 
int main()
{
	int a;  
	cin >> a;
	int ans = 0;
	for (int i = 0; i < a; i++)
	{
		int n; 
		cin >> n;
		if (n%2==0)
		{
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3124
"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    a,b = map(int,sys.stdin.readline().split())
    print(a*b)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 65308
_ = input()
input_data = input()
str_data = input_data.split(' ')
list_data = [int(i) for i in str_data]
sugoroku_final = 1
sugoroku_temp = 1
for datum in list_data:
    if datum == 1:
       sugoroku_temp += 1
    else:
        sugoroku_final = max(sugoroku_final, sugoroku_temp)
        sugoroku_temp = 1

sugoroku_final = max(sugoroku_final, sugoroku_temp)
print(sugoroku_final)


Measured memory_bytes: 5604
#Union-Find木の構築
import sys
def 解():
    iN,iK,iL = [int(_) for _ in input().split()]
    aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

    def buildTree(a):
        #aT = [0]*(iN+1)
        aT = list(range(iN+1))
        for p,q in a:
            rp = getRoot(aT,p)
            rq = getRoot(aT,q)
            thisRoot = max(rp,rq,q)
            aT[p] = thisRoot
            aT[q] = thisRoot
            aT[rp] = thisRoot #これで Union してるつもり
            aT[rq] = thisRoot
        return aT
    def getRoot(a,i): #find みんな小さい方に合わせるならデカい方に合わせてみよう
        #if a[i] == i or a[i] == 0:
        #   if a[i] == 0 : a[i] = i
        if a[i] == i :
            return i
        elif i < a[i] :
            a[i] = getRoot(a,a[i])
            return a[i]
    #   else:
    #       print("! ",i,a[i])

    aT道 = buildTree(aD[0:iK])
    aT鉄道 = buildTree(aD[iK:])
    aRet = []
    dRet = {}
    for i in range(1,iN+1):
        # いやはやこんなもんもキーになるのか。
        Comb = (getRoot(aT道,i), getRoot(aT鉄道,i))
        aRet.append(Comb)
        if Comb in dRet:
            dRet[Comb] += 1
        else:
            dRet[Comb] = 1
    print(" ".join([str(dRet[_]) for _ in aRet]))

解()


Measured memory_bytes: 95404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n; cin >> n;
  vector<int> v;

  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    v.push_back(a);
  }

  int now = 0;
  int mse = 1e+9;

  while (now <= 100) {
    int tmp_error = 0;
    for (int i = 0; i < n; i++) {
      tmp_error += pow(now - v[i], 2);
    }

    if (tmp_error < mse) {
      mse = tmp_error;
    }

    now++;
  }

  cout << mse << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define A 120
using namespace std;

int main(){
	int h, w, f = 0;
	char c[A][A];
	int re[A][A];
	cin >> h >> w;
	for (int i = 0; i<h; i++) {
		f = 0;
		for (int j = 0; j<w; j++) {
			cin >> c[i][j];
			if (c[i][j] == 'c') {
				f = 1;
				re[i][j] = 0;
			}
			else {
				if (f != 1)
					re[i][j] = -1;
				else
					re[i][j] = re[i][j - 1] + 1;

			}
		}
	}
	for (int i = 0; i<h; i++) {
		cout << re[i][0];
		for (int j = 1; j<w; j++)
			cout << " " << re[i][j];
		cout << endl;
	}
}


Measured memory_bytes: 3152
"""
1以上N以下の整数の内、各桁の輪がA以上B以下であるものの全ての総和は？

20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、
2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。
"""

N, A, B = map(int, input().strip().split(' '))
sum_list = []
for i in range(1, N + 1):
  # １以上N以下の整数を1つずつ
  if len(str(i)) == 1:
    if A <= i <= B:
      sum_list.append(i)
  elif len(str(i)) == 2:
    if A <= int(str(i)[0]) + int(str(i)[1]) <= B:
      sum_list.append(i)
  elif len(str(i)) == 3:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) <= B:
      sum_list.append(i)
  elif len(str(i)) == 4:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3]) <= B:
      sum_list.append(i)
  else:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3]) + int(str(i)[4]) <= B:
      sum_list.append(i)
print(sum(sum_list))

Measured memory_bytes: 41064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int N,M,x,y;
  cin >> N >> M;
  Vi in(N,0);
  vector<Vi> v(N);
  rep(i,M) {
    cin >> x >> y;
    v[x-1].push_back(y-1);
    in[y-1]++;
  }
  // rep(i,N){
  //   cout << in[i] << ' ' << endl;
  // }

  Vi memo(N,0);
  queue<int> q;
  rep(inix,N){
      if (in[inix]>0) continue;
      q.push(inix);
    }
  while(!q.empty()){
    int ch = q.front();q.pop();
    // cout << "ch=" << ch << endl;
    for(auto i:v[ch]){
      in[i]--;
      if (in[i]==0) {q.push(i);
      memo[i] = memo[ch]+1;}
    }
  }
  cout << *max_element(ALL(memo));
}

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

int main()
{
	string s, t;  cin >> s >> t;

	if (s.size() < t.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	int n = s.size() - t.size() + 1;
	int startIndex;
	int cnt = 0;

	string ans; for (int i = 0; i < n; i++) ans += 'z';
	string no_ans = ans;

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

		bool can = true;
		for (int j = i; j < i + t.size(); j++) {

			if (s.at(j) != '?' && s.at(j) != t.at(j - i)) can = false;

		}
		
		if (can) {
			cnt++;
			startIndex = i;
			string tmp_ans;
					
			for (int j = 0; j < startIndex; j++) {
				if (s.at(j) == '?') tmp_ans += 'a';
				else tmp_ans += s.at(j);
			}
			for (int j = startIndex; j < startIndex + t.size(); j++) {
				tmp_ans += t.at(j - startIndex);
			}
			for (int j = startIndex + t.size(); j < s.size(); j++) {
				if (s.at(j) == '?') tmp_ans += 'a';
				else tmp_ans += s.at(j);
			}
			ans = min(ans, tmp_ans);
			
		}
	
	}

		if(cnt == 0) cout << "UNRESTORABLE" << endl;
		else cout << ans << endl;
	
		return 0;	
}

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

int main(){
	vector< vector<int> > arr;
	arr.resize(3);		// ()内の数字が要素数になる
	for( int i=0; i<3; i++ ){
		arr[i].resize(3);
	}
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> arr[i][j];
        }
    }
    int x[3],y[3];
    x[0] = 0;
    for(int i=0;i<3;i++) y[i] = arr[0][i] - x[0];
    for(int i=0;i<3;i++) x[i] = arr[i][0] - y[0];
    bool check = true;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(x[i] + y[j] != arr[i][j]){
                check = false;
            }
        }
    }
    if(check == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<ll, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n;
int a[N];
ll ans;

int main() {
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) {
        if (a[i] && a[i - 1]) {
            ans++;
            a[i]--;
            a[i - 1]--;
        }
        ans += a[i] / 2;
        a[i] %= 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 640
#普通のセグ木
'''
org: 配列[list]
func: 関数 (min,max,sumなど)
unit: 初期値
'''
class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])
    # l <= x <r
    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,q = mi()
seg = SegmentTree([(1<<31) -1]*n,min,(1<<31) -1)
for _ in range(q):
    a,b,c = mi()
    if a == 1:
        print(seg.find(b,c+1))
    else:
        seg.update(b,c)



Measured memory_bytes: 10328
#input
N, K = map(int, input().split())

#output
mod = pow(10, 9) + 7
answer = 0
for i in range(K, N+2):
    answer += ((N*(N+1)//2)  - ((N-i)*(N-i+1)//2) - (i*(i-1)//2) + 1) % mod

print(answer % mod)

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

using namespace std;

int W, H, StartId, Ans;
char MapData[1000][1000];
vector<pair<int, int> > CreatureInfo[7];
int DpCount[5][1001];

const int INF = 2e9;


void clearDpArray() {
	for (int j = 0; j < 5; ++j) {
		for (int k = 0; k < 1001; ++k) {
			DpCount[j][k] = INF;
		}
	}
}

void solve() {
	int currentId, nextId, nextIdSize, next2Id, next2IdSize, xLen, yLen, currentLen;

	Ans = INF;
	for (currentId = 0; currentId <= 4; ++currentId) {
		clearDpArray();

		nextId = (currentId + 1) % 5;
		nextIdSize = CreatureInfo[nextId].size();
		for (int i = 0; i < nextIdSize; ++i) {
			xLen = abs(CreatureInfo[5][0].second - CreatureInfo[nextId][i].second);
			yLen = abs(CreatureInfo[5][0].first - CreatureInfo[nextId][i].first);
			DpCount[1][i] = xLen + yLen;
		}

		for (int cnt = 2; cnt <= 4; ++cnt) {
			next2Id = (nextId + 1) % 5;
			next2IdSize = CreatureInfo[next2Id].size();
			for (int i = 0; i < nextIdSize; ++i) {
				for (int j = 0; j < next2IdSize; ++j) {
					xLen = abs(CreatureInfo[next2Id][j].second - CreatureInfo[nextId][i].second);
					yLen = abs(CreatureInfo[next2Id][j].first - CreatureInfo[nextId][i].first);
					DpCount[cnt][j] = min(DpCount[cnt][j], DpCount[cnt - 1][i] + xLen + yLen);
				}
			}
			nextId = (nextId + 1) % 5;
			nextIdSize = CreatureInfo[nextId].size();
		}

		for (int i = 0; i < nextIdSize; ++i) {
			xLen = abs(CreatureInfo[6][0].second - CreatureInfo[nextId][i].second);
			yLen = abs(CreatureInfo[6][0].first - CreatureInfo[nextId][i].first);
			currentLen = DpCount[4][i] + xLen + yLen;
			if (currentLen < Ans) {
				Ans = currentLen;
				StartId = currentId + 1;
			}
		}
	}

	if (Ans == INF) {
		cout << "NA" << endl;
		return;
	}
	cout << StartId << " " << Ans << endl;
}

int main() {
	char ch;

	while (cin >> W >> H, W) {
		for (int i = 0; i < 7; ++i) {
			CreatureInfo[i].clear();
		}

		memset(MapData, '\0', sizeof(MapData));
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> ch;
				if (ch == 'S') {
					CreatureInfo[5].push_back(make_pair(i, j));
				}
				else if (ch == 'G') {
					CreatureInfo[6].push_back(make_pair(i, j));
				}
				else if (ch >= '1' && ch <= '5') {
					CreatureInfo[ch-'1'].push_back(make_pair(i, j));
				}
				MapData[i][j] = ch;
			}
		}
		solve();
	}

	return 0;
}



Measured memory_bytes: 4124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = in.nextInt();
		}
//		a = insertionSort(a,n);
		a = selectionSort(a,n);
		
		in.close();

	}

	int[] insertionSort(int[]a, int n){
		for(int i = 1; i < n; i++){
			printArray(a);
			int v = a[i];
			int j = i - 1;
			while(j >= 0 && a[j] > v){
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
		}
		return a;
	}
	int[] selectionSort(int[] a, int n){
		int count = 0;
		for(int i = 0; i < n; i++){
//			printArray(a);
			int minj = i;
			for(int j = i; j < n;j++){
				if(a[j] < a[minj]) minj = j;
			}
			if(minj != i){
				int tmp = a[i];
				a[i] = a[minj];
				a[minj] = tmp;
				count++;
			}
		}
		printArray(a);
		System.out.println(count);
		return a;
	}
	void printArray(int[] a){
		System.out.print(a[0]);
		for(int i= 1; i < a.length; i++){
			System.out.print(" " + a[i]);
		}
		System.out.println();
	}

}

Measured memory_bytes: 26248
S = input()

direct = 'NWSE'
cnt = {}
ans = "Yes"

for ch in direct:
    cnt[ch] = S.count(ch)

if cnt['N'] == 0 and cnt['S'] != 0:
    ans = "No"
elif cnt['N'] != 0 and cnt['S'] == 0:
    ans = 'No'
elif cnt['E'] != 0 and cnt['W'] == 0:
    ans = 'No'
elif cnt['E'] == 0 and cnt['W'] != 0:
    ans = 'No'

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
    int len = vp.size(); s << "\n";
    for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size(); s << "\n";
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
    int len = v.size(); s << "\n";
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) { s << vv[i]; }
    return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) { s << vv[i]; }
    return s;
}

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << "\n";

    return 0;
}


Measured memory_bytes: 760
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,m,a[100005]={0},b[100005]={1},ans=0,x,y;
  cin >> n >> m;
  for(int i=0; i<=n; i++) {
    b[i]=1;
  }
  a[1]=1;
  for(int i=0; i<m; i++) {
    cin >> x >> y;
    if(a[x]==1) {
      a[y]=1;
      if(b[x]!=1) {
        a[x]=1;
      }
      else {
        a[x]=0;
      }
      b[x]--,b[y]++;
    }
    else {
      b[x]--,b[y]++;
    }
  }
  for(int i=1; i<=n; i++) {
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
R = INT()
print(float(2*R*pi))

Measured memory_bytes: 10048
#include<stdio.h>

int main(void){

int x,min,max,a,i;

long int sum;

scanf("%d",&x);

scanf("%d",&a);

max=a;

min=a;

sum=a;

for(i=1;i<x;i++){

scanf("%d",&a);

sum+=a;

if(a<min){

min=a;

}

if(a>max){

max=a;

}

}

printf("%d %d %ld\n",min,max,sum);

return 0 ;

}

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

int main() {
  int n;
  string s[200010];
  int c = 0;
  int s_max;
  cin >> n;

  for ( int i=0 ; i < n ; ++i ) {
    cin >> s[i];  
  }
  sort(s,s + n);
  for ( int i=0 ; i < n ; ++i ) {
    //cout << s[i] << endl;
    if (i==0) {
      c = 1;
      s_max = 1;
    }
    else if (s[i] == s[i-1]) {
      c++;
      if (c > s_max) s_max = c;
    }
    else {
      c=1;
    }
  }
  for ( int i=0 ; i < n ; ++i ) {
    if (i==0) {
      c = 1;
    }
    else if (s[i] == s[i-1]) {
      c++;
    }
    else {
      c=1;
    }
    if (c==s_max) cout << s[i] << endl;
  }  
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int a,b;
	cin>>a>>b;

	int t=0;

	t=max(a+b,a-b);
	cout<<max(t,a*b)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        BigInteger BI = new BigInteger(S);
        long Sum = 0;

        for (int I = 0; I < S.length(); I++) {
            Sum += Integer.parseInt(S.charAt(I) + "");
        }

        BigInteger BX = new BigInteger(Sum + "");

        BigInteger X = new BigInteger(BI.mod(BX) + "");
        BigInteger CC = new BigInteger("0");

        if (X.equals(CC)) {
            System.out.println("Yes");
        }else{System.out.println("No");}
    }

}


Measured memory_bytes: 23764
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  vector<ll> A(N), B(N);
  
  REP(i, N)
    cin >> A[i] >> B[i];
  
  bst::sort(A);
  bst::sort(B);
  if (N % 2 == 0) {
    ll low = A[N/2]+A[N/2-1], high = B[N/2]+B[N/2-1];
    
    return high - low + 1;

  }
  else {
    ll low = A[N/2], high = B[N/2];
    
    return high - low + 1;
  }
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 6424
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
    long long n, m, k; cin >> n >> m >> k;
    
    vector<long long> A(n + 1), B(m + 1), a(n + 1), b(m + 1);
  	
    for(long long i = 1; i <= n; i++) {
   		cin >> A[i];
   		a[i] = a[i - 1] + A[i];
   	}
    
    for(long long i = 1; i <= m; i++) {
   		cin >> B[i];
   		b[i] = b[i - 1] + B[i];
   	}
   	
   	long long ans = 0;
   	for(long long i = 0; i <= n; i++) {
   		if(a[i] > k) break;
   		long long low = 0, high = m, j = low;
   		while(low <= high) {
   			long long mid = low + (high - low) / 2;
   			if(b[mid] <= k - a[i]) {
   				low = mid + 1;
   				j = mid;
   			}
   			else {
   				high = mid - 1;
   			}
   		}
   		ans = max(ans, i + j);
   	}
   	
   	cout << ans;
   	
    return 0;
}


Measured memory_bytes: 9528
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vi a(N);
	for (auto& x : a)
		cin >> x;
	int ct = 0;
	for (int i = 0; i < N; ++i)
	{
		if (i % 2 == 0 && a[i] % 2 == 1)
			++ct;
	}
	cout << ct << endl;
	return 0;
}


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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define mod 1000000007

int main()
{
    Coming
     
    int a,b,c;
    
    cin >> a>> b >>c;
    
    int s = (a+b+c) / 2;
    
    
    int ans = sqrt(s*(s-a)*(s-b)*(s-c));
    
    cout << ans << endl;
    	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char str[33];
int UF[26];
int in[26];
int out[26];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);
	b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<26;i++){
			in[i]=out[i]=0;
			UF[i]=-1;
		}
		for(int i=0;i<a;i++){
			scanf("%s",str);
			in[str[0]-'a']++;
			out[str[strlen(str)-1]-'a']++;
			UNION(str[0]-'a',str[strlen(str)-1]-'a');
		}
		bool dame=false;
		int oya=-1;
		for(int i=0;i<26;i++){
			if(in[i]!=out[i])dame=true;
			else if(in[i]>0){
				if(oya==-1)oya=FIND(i);
				else if(oya!=FIND(i))dame=true;
			}
		}
		if(dame)printf("NG\n");
		else printf("OK\n");
	}
}

Measured memory_bytes: 0