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

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;

int main(){
    //freopen("in.txt", "r", stdin);
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    s[k-1] = s[k-1]+32;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

def make_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divs = make_div(n)
ans=0
for r in divs:
    m=n//r -1
    if r<m:
        ans+=m
print(ans)

Measured memory_bytes: 39152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define debug(x) cerr<<#x<<'='<<x<<'\n'
bool check(int a, int b, int c) {
	for (int i=0; i*a<=c; i++) {
		for (int j=0; j*b<=c; j++) {
			if (a*i+b*j==c) {
				return true;
			}
		}
	}
	return false;
}
int main(void) {
//	debug(check(3, 5, 15));
	int a, b, c, d, e, f;
	cin>>a>>b>>c>>d>>e>>f;
	double ans=-1;
	int answ, ansg;
	a*=100; b*=100;
//	int w=__gcd(a, b);// debug(w);
//	int g=__gcd(c, d);// debug(g);
//	debug(f);
	for (int i=1; i<=f; i++) {
	//	if (i==1500) debug(i%w);
		if (!check(a, b, i)) continue;
	//	debug(i); getchar();
	//	if (i==1700) debug(1.0*i/100*e);
		for (int j=0; j<=f-i && j<=1.0*i/100*e; j++) {
		//	debug(934-934/22*22);
			if (!check(c, d, j)) continue;
		//	debug(j); getchar();
		//	if (i==1700 && j==934) {
		//		debug(1.0*j/(i+j));
		//		debug(ans);
		//	}	
		//	debug(1.0*j/(i+j));
		//	debug(j);
			//getchar();
			if (1.0*j/(i+j)>ans) {
		//		debug(i);
			//	debug(j);
			//	getchar();
				answ=i;
				ansg=j;
				ans=1.0*j/(i+j);
			}
		}
	}
	//debug(ans); 
	cout<<answ+ansg<<' '<<ansg<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

int n,tmp;
vi v;
ll ans;
int main(void){
    cin>>n;
    rep(i,2*n){
        cin>>tmp;
        v.pb(tmp);
    }
    sort(all(v));
    rep(i,n){
        d(v[v.size()-2*i])
        ans+=min(v[v.size()-1-2*i],v[v.size()-2*i-2]);
    }
    p(ans);
    return 0;
}



Measured memory_bytes: 256
fun main() {
    val (n, m) = nextIntList()
    var x = 0
    var count = 0
    (1..m).map {
        val (a, b) = nextIntList()
        a to b
    }.sortedBy { it.second }.forEach { (a, b) ->
        if (x < a) {
            x = b - 1
            count++
        }
    }
    println(count)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 74092
#include <stdio.h>
 int main()
 {
   int n;
   scanf("%d",&n);
   int q=n/1000;
   int r=n%1000;
   if(r==0)
   {
     printf("0");
   }
   else
   {
   printf("%d",((q+1)*1000)-n);
   }
          
   return 0;
 }

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

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


Measured memory_bytes: 3828
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine());
        pw.println((N - 1) / 2);

        pw.close(); 
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int x;
    public int y;

    Pair(int _x, int _y){
        x = _x;
        y = _y;
    }
 
    public String toString(){
        return x + " " + y;
    }

    public int compareTo(Pair p){
        if (x != p.x) return x < p.x ? -1 : 1;
        if (y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 21200
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    ans = 0
    for a in A:
        while a % 2 == 0:
            a //= 2
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	long long tot1 = 0;
	double tot2 = 0;
	while (n--) {
		string x, u;
		cin >> x >> u;

		if (u == "JPY")
			tot1 += stoll(x);
		else
			tot2 += stod(x);
	}

	printf("%.10lf", tot1 + tot2 * 380000);

	return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int n,k;
int a[2005];

int main() {

    cin >> n >> k;

    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }

    int inner_inv = 0;
    int connected_inv = 0;

    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            connected_inv += (a[j] > a[i]);
        }
        for(int j = 1;j < i;j++){
            inner_inv += (a[j] > a[i]);
        }
    }

    cout << ((1LL * k * inner_inv % MOD) + ((1LL * connected_inv * ((1LL * (k) * (k - 1) / 2) % MOD)) % MOD)) % MOD << "\n";

    return 0;
}


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

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

using namespace std;

int main(){
  ll a,b,k;cin>>a>>b>>k;

  rep(i, k){
    if(i%2==0){
      if(a%2)a--;
      b+=(a/=2);
    }else{
      if(b%2)b--;
      a+=(b/=2);
    }
//  cout<<a<<' '<<b<<endl;

  }

  cout<<a<<' '<<b;

  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f,maxn=804;
queue<int>q;
int a[maxn][maxn],n,m,k,vis[maxn][maxn],sx,sy,mina;
int lrud[5]={0,1,0,-1,0};
int Get(int i,int j)
{
	int tmp=(i+k-2)/k;
	tmp=min(tmp,(j+k-2)/k);
	tmp=min(tmp,(n-i+k-1)/k);
	tmp=min(tmp,(m-j+k-1)/k);
	return tmp;
}
void bfs()
{
	int i;
	vis[sx][sy]=0;
	q.push(sx);q.push(sy);
	while(!q.empty())
	{
		int x=q.front();q.pop();int y=q.front();q.pop();
	
		if(vis[x][y]==k)
			continue;
		for(i=1;i<=4;i++)
		{
			int gx=x+lrud[i-1];
			int gy=y+lrud[i];
			if(gx<1 || gy<1 || gx>n || gy>m || vis[x][y]+1>=vis[gx][gy] || a[gx][gy]==1)
				continue;
			vis[gx][gy]=vis[x][y]+1;
			q.push(gx);q.push(gy);

		}
	}
}
int main()
{
	int i,j,ans=0;
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			vis[i][j]=INF;
			char c;
			cin>>c;
			if(c=='.')
				a[i][j]=0;
			else
				if(c=='#')
					a[i][j]=1;
				else
				{
					sx=i,sy=j;
					a[i][j]=0;
				}
		}
	}
	mina=INF;
	bfs();
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(vis[i][j]!=INF)
			{	mina=min(mina,Get(i,j)+1);
			}
		}
	}
	cout<<mina;
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstdint>
#include <valarray>

using namespace std;

int main(void) {
    int N;
    long long K;
    
    cin >> N >> K;

    valarray<long long> s(0LL, 100000);
    for (int n = 0; n < N; n++) {
        int a, b;
        cin >> a >> b;
        s[a - 1] += b;
    }

    for (int n = 0; n < 100000; n++) {
        K -= s[n];
        if (K <= 0) {
            cout << n + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DForest {
public:

#include<vector>

    std::vector<int> par;
    std::vector<int> rak; // number of the vertices
    void init(int n) {
      par.resize(n);
      rak.resize(n);
      for(int i=0; i<n; i++) {
        par[i] = i;
        rak[i] = 1;
      }
    }

    int find(int x) {
      if (par[x] == x) {
        return x;
      } else {
        return par[x] = find(par[x]);
      }
    }
    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;
      if (rak[x] < rak[y]) {
        rak[y] += rak[x];
        par[x] = y;
      } else {
        rak[x] += rak[y];
        par[y] = x;
      }
    }

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

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      init(n);
      rep(i, m) {
        int x, y; cin >> x >> y;
        unite(x, y);
      }

      set<int> parents;
      rep(i, n) {
        parents.insert(find(i));
      }
      unordered_map<int, int> mp;
      int r = 0;
      for(auto e: parents) {
        mp[e] = r;
        r++;
      }
      debug(r);
      if ((r-1)*2 > n) {
        cout << "Impossible" << endl;
        return;
      }
      if (r==1) {
        cout << 0 << endl;
        return;
      }
      vector<int> vec[r];
      rep(i, n) {
        vec[mp[find(i)]].push_back(a[i]);
      }
      rep(i, r) {
        sort(all(vec[i]));
      }
      ll ans = 0;
      vector<int> v;
      rep(i, r) {
        ans += vec[i][0];
        for(int j=1; j<vec[i].size(); j++) {
          v.push_back(vec[i][j]);
        }
      }
      int k = (r-1)*2 - r;
      sort(all(v));
      rep(i, k) {
        ans += v[i];
      }
      cout << ans << endl;
    }
};

signed main() {
  DForest solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 10276
#include <bits/stdc++.h>
using namespace std;
int main() {

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

    if( a > b ) swap(a,b);

    if( b - ( a+w ) <= 0 ) cout << "0\n";
    else cout << b - ( a+w ) << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    int count=0;
    cin>>N;
    rep(i,N){
        int a;
        cin>>a;
        if(a != i+1)count++;
    }
    if(count==0 || count==2){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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;
}

const ll mod = 998244353;





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust" << endl; 
    }else{
        cout << "win" << endl;
    }


    return 0;

}


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

int main(){
    int h, w;
    cin >> h >> w;
    char masu[105][105];
    int check_tate[105];
    int check_yoko[105];
    for(int i = 0; i < 105; i++){
        check_yoko[i] == 0;
        check_tate[i] == 0;
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            masu[i][j] = c;
            if(c == '#'){
                check_tate[j] = 1;
                check_yoko[i] = 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(check_tate[j] == 1 && check_yoko[i] == 1){
                cout << masu[i][j];
            }
        }
        if(check_yoko[i] == 1){
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,sum=0;
        cin>>n;
        ll A[n][2];
        for(ll i=0;i<n;i++)
        {
            cin>>A[i][0]>>A[i][1];
            sum=sum+(A[i][1]-A[i][0]+1);
        }
        cout<<sum;
    } 
    return 0;
}


Measured memory_bytes: 3656
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[int(_) for _ in input().split()]
    sumA,sumB=sum(A),sum(B)
    if sumA<sumB:
        print(-1)
        sys.exit()
    D=[0]*n
    sum_plus,sum_minus,ans=0,0,0
    for i in range(n):
        diff=A[i]-B[i]
        if diff>0:
            D.append(diff)
        elif diff<0:
            sum_minus-=diff
            ans+=1
    D.sort(reverse=True)
    if sum_minus==0:
        print(0)
        sys.exit()
    for d in D:
        ans+=1
        if sum_minus<=d:
            print(ans)
            break
        sum_minus-=d

if __name__=='__main__':
    main()

Measured memory_bytes: 76336
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    ll num = 0;
    for (ll i = 0; i < n;i++)
    {
        if(s[i]=='R')
            r.push_back(i+1);
        if(s[i]=='G')
            g.push_back(i+1);
        if(s[i]=='B')
            b.push_back(i+1);
    }
    for(auto i:r)
        for(auto j:g)
            for(auto k:b)
            {
                if(2*j==i+k)
                    continue;
                if(2*k==i+j)
                    continue;
                if(2*i==j+k)
                    continue;
                num++;
            }
    cout << num;
    return 0;
}

Measured memory_bytes: 3224
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  [n,a] <- getInts
  print $ minimum $ map (solve n a) [1..4*12]

solve :: Z->Z->Z->Z
solve n a c = let
  b0 = floor $ (fint n + 0.5) ** (1 / fint c)
  b1 = b0+1
  m0 = head [m | (m,bs) <- zip [0..] $ iterate (\ x -> (x`div`b0) * b1) (b0^c), bs >= n]
  in  b0*(c-m0) + b1*m0 + a*(c-1)


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 636
#include<stdio.h>
int s[100];

int main(){
  int n,k;
  int i,j;
  while(1){
    scanf("%d %d",&n,&k);
    if(n==0)return 0;
    for(i=0;i<k;i++)scanf("%d",&s[i]);
    for(i=0;i<n;i++){
      for(j=0;j<k;j++){
	int x;
	scanf("%d",&x);
	s[j]-=x;
      }
    }
    for(i=0;i<k;i++)if(s[i]<0)break;
    if(i==k)printf("Yes\n");
    else printf("No\n");
  }
}

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

const int maxn = 1e5+10;

map<vector<int>, int> mp;

int n;
long long ans;
string s;

int main() {
	cin >> n;
	while (n--) {
		vector<int> v(26);
		cin >> s;
		for (int i = 0; i < (int)s.size(); ++i)
			v[s[i]-'a']++;
		ans += mp[v]++;
	}
	cout << ans;
}


Measured memory_bytes: 18944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	ll m   = 0;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll h;
		cin >> h;
		if (h >= m) ans++;
		m = max(h, m);
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(n: usize));
  (1..=n)
    .map(|d| {
      let a = d;
      let n = n / d;
      n * (2 * a + (n - 1) * d) / 2
    })
    .sum::<usize>()
    .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "4\n" => "23\n",
    test2: "100\n" => "26879\n",
    test3: "10000000\n" => "838627288460105\n",
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,sum, a, p;
  cin>>n;
 
  for(int j=0; j<n; j++){
    p=0;
    cin>>a;
    
    for(int k=0; k>=0; k++){
      if(a%2==1){
        break;
      }
      a/=2;
      p++;
      //cout << ":" <<  p << endl;
    }
    if(sum>p|j==0){
      sum=p;
      //cout << "goukei:" <<  sum << endl;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def partition(a, p, r)
 p,r = 0,a.size-1
 x = a[r]
 i = p-1
 p.upto(r-1) do |j|
  if a[j] <= x
   i += 1
   a[i],a[j] = a[j],a[i]
  end
 end
 a[i+1],a[r] = a[r],a[i+1]
 return i+1
end

n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
q = partition(a, 0, n - 1)
a[q] = "[#{a[q]}]"
puts a.join(" ")

Measured memory_bytes: 17580
s = input()
t = input()

flag = 0

for i in range(len(s)):
    s1 = s[0:-1]
    s2 = s[-1]
    s = s2 + s1
    if(s == t):
        flag = 1
        break

if(flag == 1):
    print("Yes")
else:
    print("No")

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int N,M,Q;
vector<int> A;
vector<int> a,b,c,d;
int res = 0;

void dfs(int i){
  if(i==N){
    // rep(i,N)cout<<A.at(i)<<" ";
    // cout<<endl;
    int tmp = 0;
    rep(j,Q)if(A.at(b.at(j)-1)-A.at(a.at(j)-1)==c.at(j))tmp+=d.at(j);
    // cout<<tmp<<endl;
    res = max(res,tmp);
  }else{
    if(i==0){
      rep1(j,M){
        A.at(i)=j;
        dfs(i+1);
      }
    }else{
      for(int j = A.at(i-1); j <= M; j++){
        A.at(i) = j;
        dfs(i+1);
      }
    }
  }
}

int main(){
  cin>>N>>M>>Q;
  A.resize(N);
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  rep(i,N)A.at(i)=1;
  rep(i,Q)cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
  dfs(0);
  cout<<res<<endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	vector<int> score(n);
	rep(i, 0, n)score[i] = k - q;
	rep(i, 0, q) {
		cin >> a[i];
		score[a[i] - 1]++;
	}
	rep(i, 0, n) {
		if (score[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

int n, m, k;
char s[7][7];

int main () {
    while (scanf("%d %d %d", &n, &m, &k) == 3) {
        for (int i = 0; i < n; i++) scanf("%s", s[i]);

        int res = 0;
        for (int xm = 0; xm < (1 << n); xm++)
            for (int ym = 0; ym < (1 << m); ym++) {
                int t = 0;
                for (int i = 0; i < n; i++) 
                    for (int j = 0; j < m; j++) {
                        if (xm >> i & 1) continue;    
                        if (ym >> j & 1) continue;
                        t += s[i][j] == '#';
                    }
                res += t == k;
            }
        printf("%d\n", res);
    }
}



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

using ll = long long;

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

    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];

    sort(a.begin(),a.end());

    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1]*2)ans=i;
        a[i]+=a[i-1];
    }

    cout<<n-ans<<"\n";

    return 0;
}


Measured memory_bytes: 3960
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

if sum(b) > sum(a):
    print(-1)
    exit()

d = [a[i]-b[i] for i in range(n)]
d = sorted(d)

minus_sum = 0
minus_count = 0
for i in range(n):
    if d[i] < 0:
        minus_sum += d[i]
        minus_count += 1

ans = 0
for i in range(n)[::-1]:
    if minus_sum >= 0:
        print(ans+minus_count)
        exit()
    minus_sum += d[i]
    ans += 1


Measured memory_bytes: 85552
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc118_d(){
    //入力
    ll n,t;
    cin >> n >> t;
    ll ans = 0;
    ll time[210000]={};
    for(int i=0; i<n; ++i) cin >> time[i];
    
    //処理
    REP(i,n-1){
        if(time[i+1]-time[i]<=t) ans += time[i+1]-time[i];
        else ans += t;
    }
    ans += t;
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<vector<i64>> g;
int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<i64> d(n + 1, -1);
  d[1] = 0;
  queue<i64> q;
  q.push(1);
  while (!q.empty()) {
    i64 u = q.front(); q.pop();
    for (i64 v : g[u]) {
      if (d[v] < 0) {
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  cout << (d[n] == 2 ? "POSSIBLE" :"IMPOSSIBLE") << '\n';
  return 0;
}



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

int main() {
	long long N, P;
	int X;
	cin >> N;
	X = log10(N);
	P = pow(10, X);
	if ((N + 1) % P == 0) cout << N / P + X * 9;
	else cout << N / P + X * 9 - 1;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a, b;
    cin >> a >> b;
    ll x, y;
    y = (b - 2 * a) / 2;
    x = a - y;
    if (x >= 0 && y >= 0 && x * 2 + y * 4 == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int r, g;

    cin >> r >> g;

    cout << (g - r) + g << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()


struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, k;
int p[200200];

int ex[200200];

signed main() {

    cin >> n >> k;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
        ex[i] = ex[i-1] + p[i];
        if(i >= k) 
            chmax(ans, ex[i]-ex[i-k]);
    }

    cout << (ans+k)/2.0 << endl;
  
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
    int key;
    struct node *right, *left, *p;
};

typedef struct node Node;

Node *NIL, *T;

void insert(Node *z){
    Node *y = NIL;
    Node *x = T;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z->p = y;

    if(y == NIL){
        T = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else y->right = z;
}

void inorder(Node *i){
    if(i == NIL) return;
    inorder(i->left);
    printf(" %d", i->key);
    inorder(i->right);
}

void preorder(Node *i){
if(i == NIL) return;
printf(" %d", i->key);
preorder(i->left);
preorder(i->right);
}

int main(void){
    int nm, i, inp;
    char wd[10];
    Node *z;

    scanf("%d", &nm);
    for(i = 0; i < nm; i++){
        scanf("%s", wd);
        if(strcmp(wd,"insert") == 0){
            scanf("%d", &inp);
            z = (Node *)malloc(sizeof(Node));
            z->key = inp;
            z->left = NIL;
            z->right = NIL;
            insert(z);
        }
        else if(strcmp(wd, "printf")){
            inorder(T);
            printf("\n");
            preorder(T);
            printf("\n");
        }
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

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

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

    b = 2*b;

    int x = max(0, a - b);

    cout<<x<<endl;


}


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

int main() {
   int N;
  cin >> N;
  int X;
  int Y;
  int sum = 0;
   for(int i = 0;i < N;i++){
   cin >> X;
     cin >> Y;
     sum += Y - X + 1;
}
  cout << sum << endl;
}


Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map(map int . words) . lines
printer = unlines . (:[]) . show

solver ([n,m]:kas) = length . filter (==n) . map length . L.group . L.sort . concat . map tail $ kas
    



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

using Weight=int;
struct Edge {
    int src,dest; Weight weight;
    bool operator<(const Edge &rhs)const{
        return weight<rhs.weight;
    }
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

const Weight INF=1e9;

void dijkstra(const Graph &g,int s,vector<Weight> &d)
{
    assert(0<=s && s<g.size());
    d.assign(g.size(),INF); d[s]=0;
    vector<int> used(g.size(),0);
    using P=pair<Weight,int>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({0,s});
    while(!que.empty())
    {  
        auto val=que.top(); que.pop();
        Weight dist=val.first;
        int v=val.second;
        if(used[v]) continue;
        used[v]=true;
        for(auto e:g[v])
        {
            int to=e.dest;
            Weight w=e.weight;
            if(dist+w<d[to])
            {
                d[to]=dist+w;
                que.push({d[to],to});
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;
    Graph g(n);
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k>>k;
        for(int j=0;j<k;j++)
        {
            int v;
            cin>>v;  
            Weight c;
            cin>>c;          
            g[i].push_back((Edge){i,v,c});
        }
    }
    vector<Weight> d;
    dijkstra(g,0,d);
    for(int i=0;i<n;i++)
    {
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 9920
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main()
{
	int n, m, i, j, k; cin >> n >> k;
	vector<int> a(n);
	for (int &x : a) cin >> x;
	int dp[k + 5];
	dp[0] = 0;
	for (i = 1; i <= k; i++)
	{
		dp[i] = 0;
		for (int x : a)
		{
			if (i >= x && dp[i - x] == 0) dp[i] = 1;
		}
		//cout << dp[i] << " ";
	}
	if (dp[k] == 1) cout << "First" << endl;
	else cout << "Second" << endl;




}


Measured memory_bytes: 4020
#include <iostream>
using namespace std;
int main(void){
    
    int W,H,x,y,r;
    cin >>W>>H>>x>>y>>r;
    
    if(x - r >=0 && x + r <= W && y - r >= 0 && y + r <= H){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
}


Measured memory_bytes: 3116
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	for true {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a -= d
		if a <= 0 {
			fmt.Println("No")
			return
		}
	}

}

Measured memory_bytes: 1748
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    string s;
    cin >> s;
    string p;
    if(s=="Sunny") p = "Cloudy";
    else if(s=="Cloudy") p = "Rainy";
    else if(s=="Rainy") p = "Sunny";

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int A,B,C;
  cin >> A >> B >> C;
  cout << max(0LL, C - (A - B)) << endl;

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
 
int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 3; i++){
        printf("%c", S[i]);
    }
    
    
}
 

Measured memory_bytes: 3624
#include<stdio.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
int main(){
  ll n, a[222222], s = 0;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    s += a[i];
  }
  int i=0;
  ll t=a[i];
  while(2*t < s){
    i++;
    t += a[i];
  }
  printf("%lld\n",min(2*t-s,s-2*(t-a[i])));
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 101
static const int INFTY = (1<<21);

typedef struct
{
  int d,p,color;
}SSS;

int n,M[N][N];
SSS A[N];

int prim();

int main()
{
  int i,j,cnt,v;
  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      scanf("%d",&v);
      if(v != -1)M[i][j] = v;
      else M[i][j] = INFTY;
    }
  }

  cnt = prim();

  printf("%d\n",cnt);

  return 0;
}

int prim()
{
  int min,u,sum,i;

  for(i=0;i<n;i++)
  {
    A[i].d = INFTY;
    A[i].p = -1;
    A[i].color = 0;
  }

  A[0].d = 0;
  while(1)
  {
    min = INFTY;
    u = -1;
    for(i=0;i<n;i++)
    {
      if(min > A[i].d && A[i].color != 2)
      {
        u = i;
        min = A[i].d;
      }
    }

    if(u == -1)break;
    A[u].color = 2;
    for(i=0;i<n;i++)
    {
      if(A[i].color != 2 && M[u][i] != INFTY)
      {
        if(A[i].d > M[u][i])
        {
          A[i].d = M[u][i];
          A[i].p = u;
          A[i].color = 1;
        }
      }
    }
  }
  for(i=0;i<n;i++)
  {
    if(A[i].p != -1)sum += M[i][A[i].p];
  }
  return sum;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
#define NUM 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin>>a[i];
        if(i==0) b[i]=a[i];
        else b[i]=b[i-1]+a[i];
    }
    ll ans=0;
    rep(i,n){
        ans+=a[i]*((b[n-1]-b[i])%NUM)%NUM;
    }
    ans%=NUM;
    cout<<ans;
}

Measured memory_bytes: 6412
AA1 = input().split()
AA2 = input().split()
AA3 = input().split()
AA4 = [AA1[0],AA2[0],AA3[0]]
AA5 = [AA1[1],AA2[1],AA3[1]]
AA6 = [AA1[2],AA2[2],AA3[2]]
AA7 = [AA1[0],AA2[1],AA3[2]]
AA8 = [AA1[2],AA2[1],AA3[0]]
N = int(input())
list1 = []
for i in range(N):
  b = input()
  list1.append(b)
count = 0
bingo =0
for i in list1:
  if i in AA1:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA2:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA3:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA4:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA5:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA6:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA7:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
for i in list1:
  if i in AA8:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
if bingo ==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9228
import java.util.*;

public class Main {	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			int cout = 0;
			while(temp % 2 == 0) {
				temp /= 2;
				cout++;
			}
			ans += cout;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34028
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

int dp[1<<17];

pii p[maxn];

int main(){
	memset(dp,0x3f,sizeof(dp));
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		p[i].fs=x;
		for(int j=1;j<=y;j++){
			int k;
			scanf("%d",&k);
			p[i].se|=(1<<k-1);
		}
	}
	dp[0]=0;
	int N=1<<n;
	for(int i=1;i<=m;i++){
		for(int j=0;j<N;j++){
			dp[j|p[i].se]=min(dp[j|p[i].se],dp[j]+p[i].fs);
		}
	}
	if(dp[N-1]==inf) printf("-1");
	else printf("%d\n",dp[N-1]);
	return 0;
}

Measured memory_bytes: 2688