akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for(int i=0; i<(n); i++)
    int main()
    {
        int a, b, k;
        cin >> a >> b >> k;
     
        for(int i=a; i<=b; i++){
            if(i < a+k && i > b-k){
                cout << i << endl;
            }
            else if(i < a+k){
                cout << i << endl;
            }
            else if(i > b-k){
                cout << i << endl;
            }
        }
     
        return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,ans[30005],lst,cnt;
bool ok=0;
int main()
{
	scanf("%d",&n);
	if(n==3){printf("2 5 63");return 0;}
	for(int i=2;i<=30000&&n>0;i+=2)
	{
		lst+=i;
		n--;
		ans[++cnt]=i;
		if(n%2==0&&lst%3==0&&n<=5000)
		{
			for(int j=3;n>0&&j<=30000;j+=6) ans[++cnt]=j,n--;
			ok=1;
			break;
		}
		if(ok) break;
	}
	printf("2");
	for(int i=2;i<=cnt;i++) printf(" %d",ans[i]);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int a, b; cin >> a >> b;

  float a_min, a_max, b_min, b_max;
  a_min = a / 0.08;
  a_max = (a + 1) / 0.08;
  b_min = b / 0.1;
  b_max = (b + 1) / 0.1;

  if (a_min <= b_min && b_min <= a_max && ceil(b_min) < a_max) {
    cout << ceil(b_min) << endl;
  } else if (b_min <= a_min && a_min <= b_max && ceil(a_min) < b_max) {
    cout << ceil(a_min) << endl;
  }else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
U = 2*10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
  fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  z = fact[n]
  z *= fact_inv[k]
  z %= MOD
  z *= fact_inv[n-k]
  z %= MOD
  return z

n, k = map(int, input().split())
l = k-1
A = sorted(list(map(int, input().split())))
m, M= 0, 0
for i in range(n-l):
  c = comb(n-1-i, l)
  m += A[i]*c
  m %= MOD
  M += A[n-1-i]*c
  M %= MOD
print((M-m)%MOD)

Measured memory_bytes: 172760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    void sovle(){
        int N,K;
        cin>>N>>K;
        ll ans=0;
        for(int b=1;b<=N;b++){
            int p=N/b,r=N%b;
            ans+=(ll)p*max(0,b-K);
            ans+=(ll)max(0,r-K+1);
        }
        if(K==0)ans-=N;
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->sovle();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<climits>

#define INF (1<<29)
#define all(c) (c).begin(),(c).end()

using namespace std;

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

string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(void){

  int h,w;
  cin >> h >> w;
    string s;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> s;
	if(s=="snuke"){
	  cout << a[j] << i+1 << endl;
	  break;
	}
      }
    }

  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int dp[31]={};
    dp[0]=1;dp[1]=1;dp[2]=2;
    for(int i=3;i<31;i++){
        for(int j=1;j<4;j++){
            dp[i]+=dp[i-j];
        }
    }
    while(cin>>n,n){
        int num=dp[n]/3650;
        if(dp[n]%3650!=0)num++;
        cout<<num<<endl;
    }
}

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y, z;
  int a1 = 0,a2 = 0;
  while (~scanf("%d,%d,%d",&x,&y,&z))
  {
    if(x*x+y*y==z*z) a1++;
    if(x==y) a2++;
  }
  printf("%d\n%d\n",a1,a2);
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int W , H , x , y;
  cin >> W >> H >> x >> y;
  double a = W;
  double b = a*H/2;
  
  if(( W % 2 == 0 ) && (H % 2 == 0) && (W/2 == x) && (H/2 == y) ){
    cout << fixed << setprecision(10);
    cout << b << " " << 1 << endl;
  }
  else{
    cout << fixed << setprecision(10);
    cout << b << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const int Maxn=0;
#define mod 0x3f3f3f3f
using namespace std;

int main()
{ int n,m;
cin>>n>>m;
 if(m==1)cout<<0<<endl;
 else {
    cout<<(n-m)<<endl;

 }
    return 0;
}


Measured memory_bytes: 256
//b > g > r 
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

void solve(){
    int r , g , b ;
    cin >> r >> g >> b ;
    int k ;
    cin >> k ;
    // r < g < b
    while(k--){
    	if(r>=g){
    		g *= 2 ;
    	}
    	else if(g>=b){
    		b*=2;
    	}
    }
    bool ok = false ;
    if(r<g && g<b){
    	ok = 1 ;
    }
    cout << (ok ? "Yes\n" : "No\n" ) ;
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//  cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
            var A = inputs[0];
            var B = inputs[1];
            var C = inputs[2];
            var X = inputs[3];
            var Y = inputs[4];

            long ans = 0;
            var ab = (double)(A + B) / 2;
            long min = 0;
            if (ab > C)
            {
                min = Math.Min(X, Y);
                ans += C * min * 2;
            }
            ans += (X - min) * A;
            ans += (Y - min) * B;

            ans = Math.Min(ans, C * Math.Max(X, Y) * 2);
            Console.WriteLine(ans);
        }
    }
}


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

void b()
{
  int a, k;
  string s;
  cin >> a >> s >> k;
  k = k - 1;
  string ans = "";
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == s[k])
    {
      ans += s[k];
    }
    else
      ans += "*";
  }
  cout << ans;
}
void a()
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((a > c && c > b) || (a < c && c < b))
  {
    cout << "Yes";
  }
  else
    cout << "No";
}
int main(void)
{
  a();
  // b();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    while (true) {
        if ((A % 2 == 1) || (B % 2 == 1) || (C % 2 == 1)) {
            break;
        }
        int temp_A = A;
        int temp_B = B;
        int temp_C = C;
        A = (temp_B / 2) + (temp_C / 2);
        B = (temp_A / 2) + (temp_C / 2);
        C = (temp_A / 2) + (temp_B / 2);
        ans++;
        if ((A == B) || (B == C) || (C == A)) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int cnt=0;

void selectionSort(int N, int A[]){
    int minj,tmp=0;
    for(int i=0; i<N; i++){
        minj=i;
        for(int j=i; j<N; j++){
            if(A[j]<A[minj]) minj=j;
        }
        if(A[i]>A[minj]){
            tmp=A[i];
            A[i]=A[minj];
            A[minj]=tmp;
            cnt++;
        } 
    }
}

int main(){
    int n,a[105]={};
    cin>>n;
    for(int i=0; i<n; i++)cin>>a[i];
    selectionSort(n,a);
    for(int i=0; i<n; i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vi Z_Algorithm(string s){
	int S=s.size();
	vi A(S);
	A[0]=S;
	int i=1,j=0;
	while(i<S){
		while(i+j<S&&s[j]==s[i+j]) j++;
		A[i]=j;
		if(!j){
			i++;
			continue;
		}
		int k=1;
		while(i+k<S&& k+A[k] < j){
			A[i+k]=A[k];
			k++;
		}
		i+=k;
		j-=k;
	}
	return A;
}

int f(char c){
	return c-'a';
}

string s,t;
ll l,r,S,T;

vl Solve(ll x){
	vl a(26);
	for(int i=0;i<min(S,x);i++) a[f(s[i])]++;
	if(x>S){
		for(int i=0;i<T;i++) a[f(t[i])]+=(x-S)/T;
		for(int i=0;i<(x-S)%T;i++) a[f(t[i])]++;
	}
	return a;
}

ll solve(ll x,char c){
	if(x<=S+T){
		ll res=0;
		for(int i=0;i<min(S,x);i++) if(s[i]==c) res++;
		if(x>S){
			for(int i=0;i<x-S;i++) if(t[i]==c) res++;
		}
		return res;
	}
	vl len(100),num(100);
	ll res,I=2;
	len[0]=S;
	len[1]=S+T;
	for(int i=0;i<S;i++) if(s[i]==c) num[0]++;
	for(int i=0;i<T;i++) if(t[i]==c) num[1]++;
	num[1]+=num[0];
	while(1){
		len[I]=len[I-1]+len[I-2];
		num[I]=num[I-1]+num[I-2];
		if(len[I]>x){
			res=num[I-1]+solve(x-len[I-1],c);
			break;
		}
		I++;
	}
	return res;
}

int main(){
	cin>>s>>l>>r;
	S=s.size()/2;
	s=s.substr(0,S);
	l--;
	int M=0;
	T=S;
	vi z=Z_Algorithm(s);
	for(int i=1;i<S;i++){
		if(z[i]==S-i){
			M=z[i];
			T=i;
			break;
		}
	}
	t=s.substr(0,T);
	if(S%T==0){
		vl al=Solve(l),ar=Solve(r);
		for(int i=0;i<26;i++){
			if(i) cout<<' ';
			cout<<ar[i]-al[i];
		}
		cout<<endl;
	}
	else{
		char c='a';
		for(int i=0;i<26;i++){
			if(i) cout<<' ';
			cout<<solve(r,c)-solve(l,c);
			c++;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 832
h,w,k= map(int, input().split())
c= [list(input()) for i in range(h)]

ans=0

for i in range(2**h):
    for j in range(2**w):
        cnt=0
        for i1 in range(h):
            for j1 in range(w):
                if (i >> i1) & 1 and (j>>j1)&1:
                    if c[i1][j1]=='#':
                        cnt+=1

        if cnt==k:
            ans+=1

print(ans)

Measured memory_bytes: 74076
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] xArr = new String[n];
        String[] yArr = new String[n];
        for (int i = 0; i < n; i ++) {
            xArr[i] = sc.next();
            yArr[i] = sc.next();
        }

        for (int q = 0; q < n; q++) {
            String x = xArr[q];
            String y = yArr[q];
            int nx = x.length();
            int ny = y.length();

            int[][] dp = new int[nx + 1][ny + 1];
            for (int i = 0; i < nx; i++) {
                for (int j = 0; j < ny; j++) {
                    if (x.charAt(i) == y.charAt(j)) {
                        dp[i + 1][j + 1] = dp[i][j] + 1;
                    } else {
                        dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                    }
                }
            }

            System.out.println(dp[nx][ny]);
        }

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 64284
#include <cstdio>
#include <iostream>

using namespace std;

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

    // mountains[0] の降水量を計算する
    int mountains[n];
    mountains[0] = 0;
    for (int i=0; i<n; i++) {
        mountains[0] = dams[i] - mountains[0];
    }

    // その他の山の降水量を計算する
    for (int i=0; i<n-1; i++) {
        mountains[i+1] = dams[i]*2 - mountains[i];
    }

    // 表示する
    for (int i=0; i<n; i++) {
        cout << mountains[i] << " ";
    }

    cout << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define mx 100005
using namespace std;
int prime[100005],a[100005];
void seive()
{
    prime[2]=1;
    for(int i=3;i<=mx;i+=2)prime[i]=1;
    for(int i=3;i<=sqrt(mx);i+=2)
    {
        for(int j=i*i;j<=mx;j+=i+i)
        {
            if(prime[j]==1)prime[j]=0;
        }
    }
    a[0]=0;
    a[1]=0;
    a[2]=0;
    a[3]=1;
    int sum=1;
    for(int i=4;i<=mx;i++)
    {
        if(prime[i]==1&&prime[(i+1)/2]==1)
        {
            sum+=1;
            a[i]=sum;
        }
        else a[i]=a[i-1];
    }



}
int main()
{
    int n,m,i,q,l,r,j,t;
    seive();
    while(cin>>q)
    {
        while(q--)
        {
            cin>>l>>r;

            cout<<a[r]-a[l-1]<<endl;

        }
    }

    return 0;
}



Measured memory_bytes: 1408
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N, K; cin >> N >> K;
    ll S; cin >> S;
    vecl ans(N);
    ll res;
    if(S == 1e9) res = 1;
    else res = S+1;
    REP(i,K) ans[i] = S;
    for(int i = K; i < N; i++) {
        ans[i] = res;
    }
    for(auto x: ans) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define BLK 750
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
//ll BLK;
struct query
{
    ll L,R,i;
};
query Q[1000005];
ll v[1000005],res[1000005],freq[1000005];
ll cnt = 0;
//const ll BLK = 750;
bool cmp(query a,query b)
{
    if(a.L/BLK != b.L/BLK)
    return (a.L/BLK < b.L/BLK);

    return (a.R < b.R);
    }
    bool cmp1(query a,query b)
    {
        return (a.i < b.i);
    }
void add(ll pos)
{
    freq[v[pos]]++;
    if(freq[v[pos]] == 1) cnt++;
}
void erased(ll pos)
{
    freq[v[pos]]--;
    if(freq[v[pos]] == 0) cnt--;
}
int main()
{
    KAKA
    ll n,q;
    cin>>n>>q;
    //BLK = sqrt(n);
    pragi(0,n)
    {
        cin>>v[i];
    }
    pragi(0,q)
    {
        cin>>Q[i].L>>Q[i].R;
        Q[i].i = i,Q[i].L--,Q[i].R--;
    
    }
    sort(Q,Q + q,cmp);
     ll ml = 0,mr = -1;
    pragi(0,q)
    {
        ll left = Q[i].L;
        ll right = Q[i].R;
       
        while(ml > left)
        {
            ml--;
           add(ml);
        }
        while(mr < right)
        {
         mr++;add(mr);
        }
        while(ml < left)
        {
            erased(ml);ml++;
        }
        while(mr > right)
        {
            erased(mr);mr--;
        }
        res[Q[i].i] = cnt;
    }
    sort(Q,Q + q,cmp1);
    pragi(0,q)
    {
        cout<<res[i]<<"\n";
    }
}


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


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

   int n,k,p=0; cin >> n >> k;
   double ans=0.0;
   rep(i,1,n+1){
   	 	p=i;
   	 	double res=1.0/n;
   	 	while(p<k){
           p*=2;
           res*=0.5;
   	 	}
       ans+=res;
   }
   cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N, M, S, T;
  scanf("%lld %lld", &N, &M);
  vector<vector<ll>> edges(3*N);
  rep(i, M){
    ll u, v;
    scanf("%lld %lld", &u, &v);
    edges[3*u-3].push_back(3*v-2);
    edges[3*u-2].push_back(3*v-1);
    edges[3*u-1].push_back(3*v-3);
  }
  scanf("%lld %lld", &S, &T);

  bool visited[3*N] = {};
  vector<P> nodes;
  nodes.emplace_back(3*S-3, 0);
  ll idx = 0;
  ll mindist;
  while(idx < (ll)nodes.size()){
    ll node = nodes[idx].first, dist = nodes[idx].second;
    // printf("%lld %lld\n", node, dist);
    if(node == 3*T-3){
      mindist = dist / 3;
      break;
    }
    for(auto it=edges[node].begin(); it<edges[node].end(); ++it){
      if(!visited[*it]){
        nodes.emplace_back(*it, dist+1);
        visited[*it] = true;
      }
    }
    idx++;
  }
  if(visited[3*T-3]) cout << mindist << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 26352
#include <iostream>
#include <vector>
#include <cstring>
#define f first
#define s second
using namespace std;
#define INF (1e9)
struct edge{int to,cap,rev;};

vector <edge> V[101];
int v,e;
bool visited[101];


int flow(int node,int mcap){
  visited[node] = 1;
  if(node == v-1) return mcap;

  for(int i=0;i<V[node].size();i++) {
    edge &w=V[node][i];
    if(visited[w.to] == 1 || w.cap == 0) continue;
    int res = flow( w.to ,min( w.cap,mcap));
    if(res <=0)continue;
    w.cap -= res;
    V[w.to][w.rev].cap += res;
    return res;
  }
  return 0;
}
int solve(){
  int sum=0,f;
  while(1) {
    memset(visited,0,sizeof(visited));
    f = flow(0,INF);
    if(f==0) return sum;
    sum+= f;
  }
  return sum;
}

int main(){


  cin >> v >> e;
  for(int i=0;i<e;i++) {
    int a,b,c;
    cin >> a >> b >> c;
    V[a].push_back((edge){b,c,(int)V[b].size()} ); 
    V[b].push_back((edge){a,0,(int)V[a].size()-1});
  }
  cout << solve()<<endl;
  return 0;
}

Measured memory_bytes: 1260
N,K=map(int,input().split())
ans=0

if K==0:
    print(N*N)
else:
    for b in range(K+1,N+1):
        x=N//b
        ans+=(b-K)*x
        y=N%b
        ans+=max(0,y-K+1)
    print(ans)


Measured memory_bytes: 9164
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n, x;
int a[210000];

int main () {
  while (cin >> n >> x) {
	for (int i = 0; i < n; ++i) scanf("%d", &a[i+1]);
	a[0] = 0;
	long long res = 0;
	for (int i = 1; i <= n; ++i) {
	  if (a[i] + a[i-1] > x) {
		res += a[i] + a[i-1] - x;
		a[i] = x - a[i-1];
	  }
	}
	cout << res << endl;
  }
}

	


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;

int n;
lint K;
lint a[200010], f[200010];

bool check(lint mid){
    lint cnt = 0;
    rep(i, n)if(a[i] * f[i] > mid){
        cnt += a[i] - mid / f[i];
    }
    return cnt <= K;
}

int main(){
    scanf("%d%lld", &n, &K);
    rep(i, n) scanf("%lld", &a[i]);
    rep(i, n) scanf("%lld", &f[i]);
    sort(a, a+n);
    sort(f, f+n, greater<lint>());

    lint low = -1;
    lint high = 1e12;
    while(high - low > 1){
        lint mid = (high + low) / 2;
        (check(mid) ? high : low) = mid;
    }
    printf("%lld\n", high);
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int N,M,sum=0,s=0;
	long long int a[50],b[50],c[50],d[50],ans[50],t[50];
	
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>a[i]>>b[i];
		 t[i]=10000000000;
	}
	for(int j=0;j<M;j++){
		cin>>c[j]>>d[j];
	}

	for(int i=0;i<N;i++){
		//s=abs(a[i]-c[0])+abs(b[i]-d[0]);
		for(int j=0;j<M;j++){
			s=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(s<t[i]){
				t[i]=s;
				//sum=j;
				ans[i]=j+1;
			}
			/*if(s=t){
			    t=s;
			    if(sum>j){
			        ans[i]=j;
			    }
			    if(sum<j){
			        ans[i]=sum;
			    }
			}*/
			//sum=j;
		}
		cout<<ans[i]<<endl;
	}
	

	/*for(int i=0;i<N;i++){
	  
	}*/
	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit()
a = (x + y) // 3
x -= a
y -= a
if x < 0 or y < 0:
    print(0)
    exit()
mod = 10 ** 9 + 7
def combination(n, r):
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (r - i) % mod
    return (x * pow(y, mod-2, mod)) % mod
print(combination(x+y, min(x, y)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) std::cerr<<#x<<":"<<(x)<<std::endl;
#define INIT ios::sync_with_stdio(false);cin.tie(0);

int n,m;
int dp[1<<15][1010];
vector<int> a;
vector<int> c[1010];
vector<int> states;

signed main() {
  INIT;
  cin>>n>>m;
  a.resize(m);states.resize(m);
  for(int i=0;i<m;++i){
    cin>>a[i];
    int b;cin>>b;
    c[i].resize(b);
    int state = 0;
    for(int j=0;j<b;++j) {
      cin>>c[i][j];
      c[i][j]--;
      state |= (1<<c[i][j]);
    }
    states[i] = state;
  }

  for(int i=0;i<(1<<n);++i) fill_n(dp[i], 1010, 1e9+1);
  dp[0][0] = 0;
  
  for(int bit=0;bit<(1<<n);++bit){
    for(int j=0;j<m;++j){
      //debug(j);
      //debug(states[j]);
      if (j>0) dp[bit][j] = min(dp[bit][j], dp[bit][j-1]);
      if(dp[bit | states[j]][j] > dp[bit][j] + a[j]) {
        dp[bit | states[j]][j] = dp[bit][j] + a[j];
        /*
        debug(bit | states[j]);
        debug( dp[bit | states[j]][j]);
        */
      }
    }
  }

  int ans = 1e9+1;
  for(int i=0;i<m;++i){
    ans = min(ans, dp[(1<<n)-1][i]);
  }
  if(ans==1e9+1) ans = -1;
  cout<<ans<<endl;

  /*
  for(int i=0;i<(1<<n);++i){
    for(int j=0;j<m;++j){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  
  return 0;
}


Measured memory_bytes: 33152
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m>>k;
  vector<lol> a(n),b(m);
  for(auto&& o:a) cin >>o;
  for(auto&& o:b) cin >>o;
  map<lol,lol> ma;
  lol sum=0;
  ma[0]=0;
  lol ans=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(sum>k) break;
    chmax(ans,i+1);
    ma[sum]=i+1;
  }
  sum=0;
  for(int i=0;i<m;i++){
    sum+=b[i];
    if(sum>k) break;
    chmax(ans,i+1);
    auto u=ma.lower_bound(k-sum);
    if(u==ma.end()) u--;
    if(u->fi>k-sum) u--;
    chmax(ans,i+1+u->se);
  }
  cout <<ans<<'\n';

  return(0);
}

Measured memory_bytes: 18772
MOD=1000000007
N=int(input())
a=[int(_) for _ in input().split()]
cnt=[0]*N
if N%2==0:
    for i in range(N):
        cnt[a[i]]+=1
    f=True
    for i in range(N):
        if i%2==0 and cnt[i]!=0:
            f=False
        elif i%2==1 and cnt[i]!=2:
            f=False
    if f:
        res=1
        for i in range(N//2):
            res=(res*2)%MOD
        print(res)
    else:
        print(0)
elif N%2==1:
    for i in range(N):
        cnt[a[i]]+=1
    f=True
    for i in range(N):
        if i==0 and cnt[i]!=1:
            f=False
        elif i!=0 and i%2==0 and cnt[i]!=2:
            f=False
        elif i%2==1 and cnt[i]!=0:
            f=False
    if f:
        res=1
        for i in range((N-1)//2):
            res=(res*2)%MOD
        print(res)
    else:
        print(0)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define INF (1e9+1)
#define N 100001
using namespace std;
typedef long long ll;
ll n,m,s[N],t[N],p[N],P[N];
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>s[i]>>t[i];
  for(int i=1;i<=m;i++) cin>>p[i];
  p[m+1]=P[m+1]=INF;
  sort(p,p+m+2);
  for(int i=1;i<m+2;i++)P[i]=p[i]-p[i-1];
  for(int i=2;i<m+1;i+=2)P[i]+=P[i-2],P[i+1]+=P[i-1];
  
  ll sum=0; 
  for(int i=0;i<n;i++){
    int idx2=upper_bound(p,p+m+2,s[i])-p,idx1=idx2-1;
    int idx4=upper_bound(p,p+m+2,t[i])-p,idx3=idx4-1;

    int f;
    if(idx2==idx4)sum+=abs(t[i]-s[i]);
    else if(s[i]<t[i]){
      sum+=p[idx2++]-s[i];
      f=idx2%2==idx3%2;
      sum+=P[idx3-f]-P[idx2-1]+f*(t[i]-p[idx3]);
    } 
    else{
      sum+=s[i]-p[idx1--];
      f=idx1%2==idx4%2;
      sum+=P[idx1]-P[idx4-!f]+f*(p[idx4]-t[i]);
    }
  }
  cout <<sum<<endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	int ans;
	if (n < 105)
		ans = 0;
	else if (n < 135)
		ans = 1;
	else if (n < 165)
		ans = 2;
	else if (n < 189)
		ans = 3;
	else if (n < 195)
		ans = 4;
	else
		ans = 5;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
char field[101][101];

int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	while (cin >> N, N ){
		memset (field, 0, sizeof (field ) );
		int W, H; cin >> W >> H;
		rep (i, H ) rep (j, W ) field[i][j] = '.';
		rep (i, N ){
			int x, y; cin >> x >> y;
			x--, y--;
			field[y][x] = '*';
		} // end rep
		int S, T; cin >> S >> T;

		int res =  0;
		rep (i, H - T + 1 ){
			rep (j, W - S + 1 ){
				int curr = 0;
				for (int h = i; h < i+T; h++ ){
					for (int w = j; w < j+S; w++ ){
						if (field[h][w] == '*' ) curr++;
					} // end for
				} // end for
				res = max (res, curr ); 
			} // end rep
		} // end rep
		cout << res << endl;

	} // end while
		
	return 0;
}

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

int main() {
  int S;
  cin >> S;
  
  vector<long int> a(S+10);
  a.at(3) = 1;
  a.at(4) = 1;
  a.at(5) = 1;
  for (int i = 0; i < S+1; i++) {
    if(i > 5){
      a.at(i) = (a.at(i-1) + a.at(i-3))%1000000007;
    }
  }
  
  cout << a.at(S) << endl;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string str = Console.ReadLine();
        int hidariSUu = 0;
        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == '(')
            {
                hidariSUu++;
            }
            else
            {
                if (hidariSUu == 0)
                {
                    Console.Write("(");
                }
                else
                {
                    hidariSUu--;
                }
            }
        }
        Console.Write(str);
        for (hidariSUu=hidariSUu; hidariSUu > 0; hidariSUu--)
        {
            Console.Write(")");
        }Console.WriteLine();
        Console.ReadLine();
    }

    public static Boolean uso() { return false; }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1; //llの最大9*10^18
const int INF = pow(2, 30) - 1;

Bint gcd(Bint a, Bint b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;
    vector<Bint> vec(N);
    REP(i, N)
        cin >> vec.at(i);

    Bint ans = 1;

    REP(i,N){
        Bint tmp = ans * vec.at(i);
        Bint tmp2 = gcd(ans, vec.at(i));
        ans = tmp / tmp2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int gain[MAXN][3];

ll dp[MAXN][3];

ll solve() {
	REP(j,3) dp[0][j]=gain[0][j];
	FOR(i,1,n) REP(j,3) {
		dp[i][j]=0; REP(k,3) if(k!=j) dp[i][j]=max(dp[i][j],dp[i-1][k]+gain[i][j]);
	}
	ll ret=0; REP(i,3) ret=max(ret,dp[n-1][i]); return ret;
}

void run() {
	scanf("%d",&n); REP(i,n) REP(j,3) scanf("%d",&gain[i][j]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


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

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

	int n;
	string s;

	cin >> n;
	cin >> s;

	int Max = 0;
	int x = 0;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			x++;
		}
		else
		{
			x--;
		}
		Max = max(Max,x);
	}

	cout << Max << '\n';

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def ceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

def main():
    D, G = map(int, input().split())
    G //= 100
    pc = [list(map(int, input().split())) for i in range(D)]

    ans = int(1e9)
    for i in range(2**D):
        tmp = 0
        rest = []
        count = 0
        for j in range(D):
            if i&1:# コンプリートする問題
                tmp += (j+1) * pc[j][0] + pc[j][1]//100
                count += pc[j][0]
            else:
                rest.append((j+1, pc[j][0]))
            i >>= 1
        rest = sorted(rest, reverse=True)
        rest_point = G - tmp
        if rest_point <= 0:# すでに足りている
            ans = min(ans, count)
        elif len(rest) > 0:# 不足分を補う必要がある
            plus = ceil(rest_point, rest[0][0])
            if plus < rest[0][1]:# p-1問以内ですむ
                ans = min(ans, count + plus)
        else:# すべて使っても足りない
            pass
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3192
from math import atan, degrees

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

if a * a * b / 2 < x:
    tan_theta = 2 * (a * a * b - x) / (a ** 3)
else:
    tan_theta = (a * b * b) / (2 * x)

print(degrees(atan(tan_theta)))


Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef  long long LL;
const int N = 1e5+5;
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<=0&&b>=0)printf("Zero\n");
  else{
    if(a>0)printf("Positive\n");
    else if((b-a+1)&1)printf("Negative\n");
    else printf("Positive\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

int main()
{
    ll t, i, j, k, ans, n;

    //cin>>t;
    t = 1;
    while (t--)
    {
        ll term = 7,pos=1;
        cin>>k;
        i=0;

        while(i<=2*k && term%k)
        {
            term = (term * 10 %k + 7%k)%k;
            pos++;
            i++;
        }

        if(term%k==0)cout<<pos;
        else cout<<"-1";
    }

    return 0;
}

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

#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...);
}

long long binpow(long long a, long long n) {
    long long res = 1;
    while(n) {
        if(n & 1) (res *= a) %= MOD;
        n >>= 1;
        (a *= a) %= MOD;
    }
    return res;
}

long long mult(long long a, long long b) {
    return a * 1ll * b % MOD;
}

long long add(long long a, long long b) {
    a += b;
    if(a >= MOD) a -= MOD;
    return a;
}

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; cin >> n;

    long long x = binpow(10, n), y = binpow(9, n), z = binpow(8, n);

    cout << add((x - add(y, y) + MOD) % MOD, z);

    return 0;
}


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

int main()
{
  int a[3][3], n, b[10];
  bool m[3][3];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> a[i][j];
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
  }
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      m[i][j] = false;
      for (int k = 0; k < n; k++)
      {
        if (a[i][j] == b[k])
        {
          m[i][j] = true;
          break;
        }
      }
    }
  }
  if (m[0][0] == true && m[0][1] == true && m[0][2] == true ||
      m[1][0] == true && m[1][1] == true && m[1][2] == true ||
      m[2][0] == true && m[2][1] == true && m[2][2] == true ||
      m[0][0] == true && m[1][0] == true && m[2][0] == true ||
      m[0][1] == true && m[1][1] == true && m[2][1] == true ||
      m[0][2] == true && m[1][2] == true && m[2][2] == true ||
      m[0][0] == true && m[1][1] == true && m[2][2] == true ||
      m[0][2] == true && m[1][1] == true && m[2][0] == true)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

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

    int h1,m1,h2,m2,k;
    cin >> h1>> m1>>h2>>m2 >> k;
    int h = h1*60 + m1;
    int m = h2*60 + m2;

    cout << m-h-k;






    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include<cstring>
using namespace std;
//long long int n,W;
//long long int dp[n+1][W+1];


            
        
     
int main() {
    long long int n,W;
    cin>>n>>W;
    long long int dp[n+1][W+1];
    memset(dp,0,sizeof(dp));

    
   long long int arr[n],val[n];
    for(long long int i=0;i<n;i++){
        cin>>arr[i]>>val[i];

    }
   // cout<<knapsack(arr,val,n,W);
   for(long long int i=1;i<=n;i++){
                for(long long int j=1;j<=W;j++){

            
        
             if(arr[i-1]<=j){
                dp[i][j]=max(val[i-1]+dp[i-1][j-arr[i-1]],dp[i-1][j]);
            }
             else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<< dp[n][W];


}


Measured memory_bytes: 82320
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  for (int i = 0; i <= 10000; ++i) {
    if (c % (a+b) <= a) return !printf("%d\n", c);
    c += 60;
  }
  puts("-1");
}



Measured memory_bytes: 2744
n = int(input())
l = [[] for _ in range(n)]
for i in range(n):
    s, p = input().split()
    p = int(p)
    l[i].append(s)
    l[i].append(p)
    l[i].append(i + 1)
l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])
for i in range(n):
    print(l[i][2])

Measured memory_bytes: 38384
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

int main(void) {
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define INF 0x3f3f3f3f

#define _rep(i,a,b) for(int i=(a);i<=(b);++i)


int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    char a,b;
    string A,B;
    cin>>a>>b;
    for(int i=1;i<=b-'0';i++)
        A+=a;
    for(int i=1;i<=a-'0';i++)
        B+=b;
    if(A<B)
        cout<<A<<endl;
    else
        cout<<B<<endl;   
    
    return 0;
}

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

#define ll long long

int main()
{
    int x,i,j;
    cin>>x;
    bool dp[x+1][7];
    int A[] = {100,101,102,103,104,105};

    for(i=0;i<7;i++)
        dp[0][i]=true;

    for(i=1;i<=x;i++)   
        for(j=0;j<7;j++)
            dp[i][j]=false;
    
    for(i=1;i<=x;i++)
    {
        for(j=1;j<=6;j++)
        {
            if(i>=A[j-1])
                dp[i][j]=dp[i-A[j-1]][j] | dp[i][j-1];
            else
                dp[i][j]=dp[i][j-1];
        }
    }

    if(dp[x][6])
        cout<<"1"<<endl;
    else
        cout<<"0"<<endl;
}


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

using namespace std;

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

int main(){
  int64_t n;
  cin >> n;
  for(int64_t a = 0; a < 140; ++a){
    for(int64_t b = -140; b < 140; ++b){
      if(a * a * a * a * a - b * b * b * b * b == n){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const int INF = 1LL<<30;

int takara[1010];
int dp[1010][1<<12];

int main() {
    int N,M;
    cin>>N>>M;
    vector<int> A(M),B(M);
    rep(i,M){
        cin>>A[i]>>B[i];
        rep(j,B[i]){
            int c;
            cin>>c;
            c--;
            takara[i] |= 1 << c;
        }
    }

    rep(i,M+1) rep(msk,1<<N) dp[i][msk]=INF;
    dp[0][0]=0;

    rep(i,M) rep(msk,1<<N){
        dp[i+1][msk]=min(dp[i+1][msk],dp[i][msk]);
        dp[i+1][msk | takara[i]]=min(dp[i+1][msk | takara[i]],dp[i][msk]+A[i]);
    }

    int ans=dp[M][(1<<N)-1];
    if(ans==INF) ans=-1;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 16256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

print(N * (N+1) // 2)

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b;
    if ((a==1&&b==2)||(b==1&&a==2))
    {
        c=3;
    }
    else if ((a==3&&b==2)||(b==3&&a==2))
    {
        c=1;
    }
    else{
        c=2;
    }
    cout << c;
}


Measured memory_bytes: 256