akhauriyash/Code-Regression huggingface dataset:
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=(0);i<(n);i++)
#define rep2(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if(!e)return 1;
    if(e&1) return qpow(b,e-1)*b;
    int pwur=qpow(b,e>>1);
    return pwur*pwur;
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    sort(rall(v));
    int s1=0,s2=0;
    for(int i=0;i<n;i+=2){
        s1+=v[i];
    }
    for(int i=1;i<n;i+=2){
        s2+=v[i];
    }
    cout<<s1-s2<<enl;

    return 0;
}


Measured memory_bytes: 3612
s=sorted(input())
t=sorted(input(),reverse=True)
n=min(len(s),len(t))

for i in range(n):
    if ord(s[i])<ord(t[i]):
        print("Yes")
        exit()
    elif ord(t[i])<ord(s[i]):
        print("No")
        exit()
        
if len(s)<len(t):
    print("Yes")
else:
    print("No")

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

int main(void){
   int A,B;
   scanf("%d %d", &A, &B);
   if (A >= 13) {
      printf("%d\n",B);
   } else if (A >= 6) {
      printf("%d\n", B /2);
   } else {
      printf("%d\n",0);
   }
   return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>

using namespace std;

double y(double x){
	double y;
	y=x*x;
	return y;
}

int main(){
	int i,d,s;
	while(cin>>d){
		s=0;
		for(i=0;i<600;i+=d){
			s+=d*y(i);
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
int a[maxn],dis[maxn];
int main()
{
    int k,n;
    scanf("%d%d",&k,&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<n;i++) dis[i]=a[i+1]-a[i];
    dis[n]=a[1]+k-a[n];
    int ans=-1;
    for(int i=1;i<=n;i++) ans=max(ans,dis[i]);
    ans=k-ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>

std::pair<int, int> plus(std::pair<int, int> p1, std::pair<int, int> p2) {
	return std::make_pair(p1.first + p2.first, p1.second + p2.second);
}
std::pair<int, int> minus(std::pair<int, int> p1, std::pair<int, int> p2) {
	return std::make_pair(p1.first - p2.first, p1.second - p2.second);
}

int main() {
	int m, n;

	while (std::cin >> m, m != 0) {
		std::vector<std::pair<int, int>> shape(m);
		for (auto&& p : shape)
			std::cin >> p.first >> p.second;

		std::sort(shape.begin(), shape.end());

		std::cin >> n;
		std::set<std::pair<int, int>> stars;
		for (int i = 0; i < n; ++i) {
			std::pair<int, int> in;
			std::cin >> in.first >> in.second;
			stars.emplace(in);
		}

		for (auto&& star : stars) {
			auto offset = minus(star, shape.front());

			bool isOK = true;
			for (int i = 1; i < shape.size(); ++i) {
				if (stars.find(plus(shape[i], offset)) == stars.end()) {
					isOK = false;
					break;
				}
			}

			if (isOK) {
				std::cout << offset.first << " " << offset.second << std::endl;
				break;
			}
		}
	}
}

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

using namespace std;

const int N = 1e5;

int likes[N+1];

int main(int argc, char const *argv[]){
	
	int n;
	scanf("%d", &n);

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

	long long ans = 0;
	for(int i=0; i<n; i++) {
		if(likes[likes[i]] == i) {
			ans++;
		}
	}

	ans /= 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
function Dice(labels) {
    this.top = labels[0];
    this.back = labels[1];
    this.right = labels[2];
    this.left = labels[3];
    this.front = labels[4];
    this.bottom = labels[5];
};

Dice.prototype.turn = function(direction) {
    switch (direction) {
        case 'W':
            var tmp = this.left;
            this.left = this.top;
            this.top = this.right;
            this.right = this.bottom;
            this.bottom = tmp;
            break;
        case 'N':
            var tmp = this.front;
            this.front = this.top;
            this.top = this.back;
            this.back = this.bottom;
            this.bottom = tmp;
            break;
        case 'E':
            var tmp = this.right;
            this.right = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = tmp;
            break;
        case 'S':
            var tmp = this.back;
            this.back = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = tmp;
            break;
        case 'R':
            var tmp = this.right;
            this.right = this.front;
            this.front = this.left;
            this.left = this.back;
            this.back = tmp;
            break;
        case 'L':
            var tmp = this.left;
            this.left = this.front;
            this.front = this.right;
            this.right = this.back;
            this.back = tmp;
            break;
    }
};

Dice.prototype.clone = function() {
    return new Dice([this.top, this.back, this.right, this.left, this.front, this.bottom]);
};

Dice.prototype.isEqual = function(other) {
    return this.top == other.top &&
        this.back == other.back &&
        this.right == other.right &&
        this.left == other.left &&
        this.front == other.front &&
        this.bottom == other.bottom;
};

Dice.prototype.isEqualLabels = function(other) {
    var dice = this.clone();
    var turns = 'NEEEN'.split('');
    var i = 0;
    do {
        var j = 0;
        do {
            if (dice.isEqual(other)) {
                return true;
            }
            dice.turn('R');
        } while (j++ < 3);
        dice.turn(turns[i]);
    } while (i++ < turns.length);
    return false;
};

Dice.prototype.getRightWithTopAndBack = function(top, back) {
    var dice = this.clone();
    var turns = 'NEEEN'.split('');
    var i = 0;
    do {
        var j = 0;
        do {
            if (dice.top === top && dice.back === back) {
                return dice.right;
            }
            dice.turn('R');
        } while (j++ < 3);
        dice.turn(turns[i]);
    } while (i++ < turns.length);
    return null;
};

(function(input) {
    var p = input.split('\n');
    var labels1 = p.shift().split(' ').map(Number);
    var labels2 = p.shift().split(' ').map(Number);
    var dice1 = new Dice(labels1);
    var dice2 = new Dice(labels2);
    console.log(dice1.isEqualLabels(dice2) ? 'Yes' : 'No');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7648
K = input()
D = int(input())

mod = 10**9+7
N = len(K)
dp0 = [[0]*D for _ in range(N)]
dp1 = [[0]*D for _ in range(N)]

for k in range(int(K[0])):
    dp1[0][k%D] += 1
dp0[0][int(K[0])%D] += 1

for i in range(N-1):
    for j in range(D):
        for k in range(10):
            dp1[i+1][(j+k)%D] += dp1[i][j]
            dp1[i+1][(j+k)%D] %= mod
        for k in range(int(K[i+1])):
            dp1[i+1][(j+k)%D] += dp0[i][j]
            dp1[i+1][(j+k)%D] %= mod
        dp0[i+1][(j+int(K[i+1]))%D] += dp0[i][j]
        dp0[i+1][(j+int(K[i+1]))%D] %= mod

print((dp1[N-1][0]+dp0[N-1][0]-1)%mod)


Measured memory_bytes: 61788
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math

def main():
    A, B, C = map(int, input().split())

    D1 = (A*B) * int(math.ceil(C/2) - math.floor(C/2))
    D2 = (B*C) * int(math.ceil(A/2) - math.floor(A/2))
    D3 = (C*A) * int(math.ceil(B/2) - math.floor(B/2))

    print(min(D1,D2,D3))

if __name__ == "__main__": main()


Measured memory_bytes: 3060
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B
 */
#include <iostream>

using namespace std;

constexpr int
gcd(const int a, const int b)
{
    return a == b ? a : a > b ? gcd(a - b, b) : gcd(a, b - a);
}

int
main()
{
    int a, b;
    cin >> a >> b; cin.ignore();

    cout << gcd(a, b) << endl;

    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>

int main(){

	std::string str;

	std::getline(std::cin, str);

	for (int i = 0; i < str.size(); i++){

		if ('a' <= str[i] && str[i] <= 'z'){
			str[i] -= 32;
		}
	}

	std::cout << str << std::endl;

	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int A,B,C,D;
  std::cin >> n;
  A =n/1000;
  n = n % 1000; //iに１０００で割った余りを代入 i = 321
  B=n/100;
  n = n % 100; //iに１００で割った余りを代入 i = 21
  C =n/10;
  n = n % 10; //iに１０で割った余りを代入 i = 1;
  D =n;
  std::vector<int> ope(3);
  std::vector<char> op(3);
  std::vector<int> v = {-1,1};
  for (size_t i = 0; i < 2; i++) {
    for (size_t j = 0; j < 2; j++) {
      for (size_t k = 0; k < 2; k++) {
        if (A+v.at(i)*B+v.at(j)*C+v.at(k)*D == 7) {
          ope[0] = v.at(i);
          ope[1] = v.at(j);
          ope[2] = v.at(k);
        }
      }
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (ope.at(i) == -1) {
      op[i] = '-';
    }
    else{
      op[i] = '+';
    }
  }
  std::cout <<A<< op[0] << B << op[1] << C << op[2] << D << '=' <<7<< endl;
}


Measured memory_bytes: 256
void main() {
	auto N = ri;
	generate_prime_list(2000);
	auto res = prime_list.filter!(a => a.to!string[$-1] == '3').array;
	foreach(i; 0..N) {
		if(i != N-1)
			"%d ".writef(res[i]);
		else
			res[i].writeln;
	}
	
	foreach(i; 0..55-5) {
		if(prime_list.canFind(res[i]+res[i+1]+res[i+2]+res[i+3]+res[i+4])){
			"bad".writeln;
		}
	}
	
}

int[] prime_list;

void generate_prime_list(int N) {
	prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<vector> 
using namespace std; 
int main() {
	int a, b, c; 
	cin >> a >> b >> c; 
	if ((a*100+b*10+c)%4==0)
	{
		cout << "YES\n";
	} 
	else
	{
		cout << "NO\n";
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int F[44];

int FibonacciNumber(int n) {
    if (n == 0 || n == 1) {
        return F[n] = 1;
    }
    
    if (F[n] != -1) {
        return F[n];
    }
    
    return F[n] = FibonacciNumber(n - 1) + FibonacciNumber(n - 2);
}

int main() {
    int i, n;
    
    for (i = 0; i <= 44; i++) {
        F[i] = - 1;
    }
    
    scanf("%d", &n);
    printf("%d\n", FibonacciNumber(n));
    
    return 0;
}



Measured memory_bytes: 2112
s=input()
if len(s)%2==1:

    n1=(len(s)-1)//2
    n2=(len(s)+2)//2
    s1=s[0:n1]
    s2=s[n2:len(s)]
    if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int t1[2005][2005];
int t2[2005][2005];
int n,k;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
inline int get1(int l1,int r1,int l2,int r2)
{if (l1<0) l1=0;
if (l1>=k) return 0;
if (r1<0) r1=0;
if (r1>=k) return 0;
if (l2<0) return 0;
if (l2>=k) l2=k-1;
if (r2<0) return 0;
if (r2>=k) r2=k-1;
int ret=t1[l2][r2];
if (l1) ret-=t1[l1-1][r2];
if (r1) ret-=t1[l2][r1-1];
if (l1&&r1) ret+=t1[l1-1][r1-1];
return ret;
}
inline int get2(int l1,int r1,int l2,int r2)
{if (l1<0) l1=0;
if (l1>=k) return 0;
if (r1<0) r1=0;
if (r1>=k) return 0;
if (l2<0) return 0;
if (l2>=k) l2=k-1;
if (r2<0) return 0;
if (r2>=k) r2=k-1;
int ret=t2[l2][r2];
if (l1) ret-=t2[l1-1][r2];
if (r1) ret-=t2[l2][r1-1];
if (l1&&r1) ret+=t2[l1-1][r1-1];
return ret;
}
int main (){
	int i,j,x,y,o;
	char s[5];
	n=read();k=read()*2;o=k/2;
	for (i=1;i<=n;i++)
	{x=read();y=read();
	x%=k;y%=k;
	scanf ("%s",s);
	if (s[0]=='W') {t1[x][y]++;}
	else {t2[x][y]++;}
	}
	for (i=0;i<k;i++)
	{for (j=0;j<k;j++)
	{if (i==0&&j==0) continue;
	if (i==0) {t1[i][j]+=t1[i][j-1];t2[i][j]+=t2[i][j-1];continue;}
	if (j==0) {t1[i][j]+=t1[i-1][j];t2[i][j]+=t2[i-1][j];continue;}
	t1[i][j]+=t1[i-1][j];t1[i][j]+=t1[i][j-1];t1[i][j]-=t1[i-1][j-1];
	t2[i][j]+=t2[i-1][j];t2[i][j]+=t2[i][j-1];t2[i][j]-=t2[i-1][j-1];
	}
	}
	int al=t2[k-1][k-1],ap=t1[k-1][k-1],ans=0;
	for (i=0;i<o;i++)
	{for (j=0;j<o;j++)
	{//(i,j) (i+o,j+o) (i-o,j-o) (i-o,j+o) (i+o,j-o)
	int d1,d2,d3,d4,d5;
	i-=o;j-=o;d1=get1(i,j,i+o-1,j+o-1)-get2(i,j,i+o-1,j+o-1);i+=o;j+=o;
	i-=o;j+=o;d2=get1(i,j,i+o-1,j+o-1)-get2(i,j,i+o-1,j+o-1);i+=o;j-=o;
	i+=o;j-=o;d3=get1(i,j,i+o-1,j+o-1)-get2(i,j,i+o-1,j+o-1);i-=o;j+=o;
	i+=o;j+=o;d4=get1(i,j,i+o-1,j+o-1)-get2(i,j,i+o-1,j+o-1);i-=o;j-=o;
	d5=get1(i,j,i+o-1,j+o-1)-get2(i,j,i+o-1,j+o-1);
	ans=max(al+d1+d2+d3+d4+d5,ans);
	ans=max(ap-d1-d2-d3-d4-d5,ans);
	}
	}
	printf ("%d\n",ans);
	return 0;
}
	

Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), s[m];
  rep(i, m) {
    int k; 
    cin >> k;
    rep(j, k) {
      int tmp;
      cin >> tmp;
      tmp -= 1;
      s[i].push_back(tmp);
    }
  }
  rep(i, m) {
    int tmp;
    cin >> tmp;
    p[i] = tmp;
  }

  ll ans = 0;

  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<bool> on(n);
    // 付いているスイッチ
    rep(i, n) {
      if (bit & (1 << i)) {
        on[i] = true;
      } else {
        on[i] = false;
      }
    }
    ll cnt = 0;
    for (int k = 0; k < m; ++k) {
      int tmp = 0;
      for (int l = 0; l < s[k].size(); ++l) {
        int target = s[k][l];
        if (on[target]) tmp += 1;
      }

      if (tmp % 2 == p[k]) {
        cnt += 1;
      }
    }

    if (cnt == m) ans += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
x = int(input())
n = len(s)

pos = [[] for __ in range(256)]
for i in range(n):
    pos[ord(s[i])].append(i)

f = set()
for c in range(97, 123):
    for i in pos[c]:
        for j in range(x):
            f.add(s[i:i+j+1])
    if len(f) >= x:
        break

p = [u for u in f]
p.sort()
print(p[x - 1])

Measured memory_bytes: 3316
from fractions import gcd
from functools import reduce


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(nums):
    return reduce(lcm, nums, 1)


N = int(input())
A = list(map(int, input().split()))

x = lcm_list(A) - 1
print(sum(x % a for a in A))


Measured memory_bytes: 5332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

ll p[100000], q[100000], r[100000];
ll pq[200000];

int main()
{
	int X, Y, A, B, C;
	ll sum = 0, ans = 0;

	cin >> X >> Y >> A >> B >> C;
	rep(i, A) cin >> p[i];
	rep(i, B) cin >> q[i];
	rep(i, C) cin >> r[i];

	sort(p, p + A, greater<ll>());
	sort(q, q + B, greater<ll>());
	sort(r, r + C, greater<ll>());

	rep(i, X) pq[i] = p[i];
	rep(i, Y) pq[X + i] = q[i];

	sort(pq, pq + X + Y);

	rep(i, X + Y) sum += pq[i];

	ans = sum;

	rep(i, min(X + Y, C)) {
		sum -= pq[i];
		sum += r[i];
		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	vl v(n);
	rep(i,0,n)cin>>v[i];
	sort(all(v));
	queue<ll> q;
	reverse(all(v));
	ll ans=v[0];
	n-=2;
	bool ok=false;
	int cnt=1;
	while(n){
		--n;
		if(ok){
			ans+=v[cnt];
			cnt++;
			ok=false;
		}
		else{
			ans+=v[cnt];
			ok=true;
		}
		//cout<<'a';
	}
		
	cout<<ans<<endl;
		
	return 0;
}

Measured memory_bytes: 4848
N, M, X = map(int, input().split())
CAs = [list(map(int, input().split())) for _ in range(N)]

L = 2**N
rlt = float('inf')
sk = [0]*M

for i in range(L):
  flag = 1
  tmp = 0
  tsk = [0]*M
  lst = bin(i)[2:].zfill(N)
  for j in range(N):
    if lst[j] == '1':
      #print(i)
      tmp += CAs[j][0]
      for k in range(M):
        tsk[k] += CAs[j][k+1]
  for k in range(M):
    if tsk[k] < X:
      flag = 0
      break
  if flag == 1 and tmp < rlt:
    rlt = tmp

if rlt == float('inf'):
  print(-1)
else:
  print(rlt)

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef unsigned long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    if (a == b) {
        cout << 0 << endl;
        ret();
    }

    ll bm = INF;
    rep(i, n) {
        if (a[i] > b[i]) cmin(bm, b[i]);
    }

    cout << accumulate(a.begin(), a.end(), 0ll) - bm << endl;
}





Measured memory_bytes: 512
/* 
    Author : Jeff Ahn
    Sun 21 Jun 2020 03:32:55 PM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

signed main() {
  fastio;
  int n;
  cin >> n;
  vector<char>c(27, 'a');
  for (int i = 0; i < 26; i++) {
    c[i+1] += i;
  }
  c[0] = 'z';
  string res = "";
  while (n) {
    int co = n % 26;
    res += c[co];
    if (co == 0) {
      n -= 26;
    }
    n /= 26;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;

}


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

typedef long long ll;
const int MAX = 1e5;

int n;
int a[MAX];

ll solve(bool flag, ll sum) {
  ll res = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (flag) {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    } else {
      if (sum <= 0) {
        res += -sum + 1;
        sum = 1;
      }
    }
    flag = !flag;
  }

  return res;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", a + i);

  // 貪欲法で操作回数の最小値を求める
  // プラスから始まるパターンとマイナスから始まるパターンの2パターン試して、その小さい方が答え
  cout << min(solve(true, 0), solve(false, 0)) << endl;
  return 0;
}


Measured memory_bytes: 640
from sys import stdin
readline = stdin.readline

N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

result = 0
t = -1
for a, b in ab:
    a, b = a - 1, b - 1
    if a <= t < b:
        continue
    result += 1
    t = b - 1
print(result)


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

int main() {
  int N;
  cin >> N;
  bool you = false;
  
  rep(i, N / 7) {
    rep(j, N/ 4) {
      if(i * 7 + j * 4 == N) {
        you = true;
        break;
      }
    }
    if(you) break;
  }
  
  if(you) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int n;
  std::cin >> n;

  int t, a;
  std::cin >> t >> a;

  std::vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> h[i];
  }

  std::vector<double> temp(n);
  for (int i = 0; i < n; ++i) {
    temp[i] = std::abs((t - h[i] * 0.006) - a);
  }

  int place = 0;
  for (int i = 1; i < n; ++i) {
    if ( temp[i] < temp[place] ) place = i;
  }
  std::cout << place + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
	int N ,K;
	cin >> N >> K;
	vector<int64_t> h(N);
	for (int i = 0; i < N; i++)
		cin >> h.at(i);
	if (N <= K)
		cout << 0 << endl;
	else 
	{
		int64_t sum = 0;
		sort(h.begin(), h.end());
		reverse(h.begin(), h.end());
		for (int i = K; i < N; i++)
			sum += h.at(i);
		cout << sum << endl;
	}
	
	return 0;
}

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

int main()
{
    int h, w;
    int i, j, count = 0;
    
    cin >> h >> w;
    
    char a[h][w];
    
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> a[i][j];
            if(a[i][j] == '#') {
                count++;
            }
        }
    }
    
    if(count == h + w - 1) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
 
def calc_sum(W, T):
  S1 = sum(W[:T])
  S2 = sum(W[T:])
  return S1, S2
 
def calc_abs(S1, S2):
  return abs(S1-S2)
  
min_ = 1000
for i in range(len(W)):
  S1, S2 = calc_sum(W, i)
  j = calc_abs(S1, S2)
  if j < min_:
    min_ = j
    
print(min_)

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

int main() {
  int N;
  cin >> N;
  int a=0;
  int b=0;
  vector<int> v(N);
  for(int i=0;i<N;i++)
    cin >> v[i];
  
  for(int s=0;s<N;s++){
    for(int t=s+1;t<N;t++){
      if(v[t]>v[s]){
        int k=v[t];
        v[t]=v[s];
    	v[s]=k;
      }
    }
  }//sort
  for(int i=0;i<N;i++){
    if(i%2==0)
      a +=v[i];
    else
      b +=v[i];
      }
  cout << a-b << endl;
}


Measured memory_bytes: 256
result = []
while True:
    i = input().split()
    if i[1] == '+':
        result = result +[int(i[0]) + int(i[2])]
    elif i[1] == '-':
        result = result + [int(i[0]) - int(i[2])]
    elif i[1] == '/':
        result = result + [int(int(i[0]) / int(i[2]))]
    elif i[1] == '*':
        result = result + [int(i[0]) * int(i[2])]
    elif i[1] == '?':
        break
for i in result:
    print(i)    

Measured memory_bytes: 6732
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 105

int n,m;
int ar[N][N],dis[N][N];
int fx[]={0,1};
int fy[]={1,0};

bool valid(int x,int y){
   return x>=1&&x<=n&&y>=1&&y<=m;
}

int bfs(int x,int y){
   for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++) dis[i][j]=INT_MAX;
   }
   deque<pi>q;
   q.push_back({x,y});
   dis[x][y]=ar[x][y];
   while(!q.empty()){
      pi u=q.front();q.pop_front();
      for(int i=0;i<2;i++){
         int nx=u.F+fx[i];
         int ny=u.S+fy[i];
         if(valid(nx,ny)){
            int c=(!ar[u.F][u.S]&&ar[nx][ny])?1:0;
            if(dis[nx][ny]>dis[u.F][u.S]+c){
               dis[nx][ny]=dis[u.F][u.S]+c;
               if(c) q.push_back({nx,ny});
               else q.push_front({nx,ny});
            }
         }
      }
   }
   return dis[n][m];
}


int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin>>n>>m;
   for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
         char c;cin>>c;
         ar[i][j]=(c=='#')?1:0;
      }
   }
   cout<<bfs(1,1)<<endl;
   return 0;
}



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

int prei = 0;
vector<int> ans;

void rec(int pre[], int in[], int l, int r, int n){
    if(l >= r) return;
    int c = pre[prei++];
    int m = find(in, in + n, c) - in;
    rec(pre, in, l, m, n);
    rec(pre, in, m+1, r, n);
    ans.push_back(c);
    return;
}

int main(){
    int n; cin >> n;
    int pre[n], in[n];
    rep(i, 0, n) cin >> pre[i];
    rep(i, 0, n) cin >> in[i];

    rec(pre, in, 0, n, n);
    rep(i, 0, ans.size()) cout << ans[i] << ((i + 1 == n) ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int main() {
	vector<int>A;
	vector<int>B;

	for (int i = 0; i < 10; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < 10; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());

	int w, k;

	w = A[0] + A[1] + A[2];
	k = B[0] + B[1] + B[2];

	cout << w << " " << k << endl;

}



Measured memory_bytes: 3144
#include <cstdio>

using namespace std;

int cost(int a, int b)
{
    int rezultat = a - b;
    if (rezultat < 0)
        rezultat = -rezultat;
    return rezultat;
}

int min(int a, int b)
{
    if (a < b) return a;
    return b;
}

int indice(int x)
{
    if (x < 0)
        return 1;
    return x;
}

int main()
{
    int n(0), k(0);
    scanf("%d %d",&n,&k);

    int *costuri = new int[n + 1];
    int *v = new int[n + 1];

    scanf("%d",&v[1]);
    costuri[1] = 0;

    for (int i = 2 ; i <= n ; i++)
    {
        scanf("%d",&v[i]);
        costuri[i] = -1;
        for (int j = indice(i - k) ; j < i ; j++)
        {
            if (costuri[i] == -1 || costuri[i] > cost(v[j],v[i]) + costuri[j])
                costuri[i] = cost(v[j],v[i]) + costuri[j];
        }
    }
    printf("%d",costuri[n]);

}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n; cin >> n;
	double p[n];
	for(int i=1; i<=n; i++)
		cin >> p[i];
	double hprob[n+1][n+1];
	memset(hprob, 0, sizeof hprob);
	hprob[0][0] = 1;

	for(int i=1; i<=n; i++){
		hprob[0][i] = (1 - p[i]) * hprob[0][i-1];
		for(int j=1; j<=i; j++)
			hprob[j][i] = p[i] * hprob[j-1][i-1] + (1 - p[i]) * hprob[j][i-1];
	}

	// for(int i=0; i<=n; i++){
	// 	for(int j=0; j<=n; j++)
	// 		cout << hprob[i][j] << " ";
	// 	cout << endl;
	// }

	double ans = 0;
	for(int i=n/2+1; i<=n; i++)
		ans += (double)hprob[i][n];
	cout << fixed << setprecision(10) << ans << "\n";
	return 0;
}

Measured memory_bytes: 74076
# -*- coding: utf-8 -*-
rawS = input()
abc = []
for s in rawS:
    abc.append(s)

abc = set(abc)

answer = 100
for a in abc:
    tmp = 0
    score = 0
    for s in rawS:
        if a == s:
            score = max(score, tmp)
            tmp = 0
        else:
            tmp += 1
    score = max(score, tmp)
    answer = min(answer, score)

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,m,c,sum=0,ans=0;
cin >> n >> m >> c;
int b[m];
for(int i=0;i<m;i++){
   cin >> b[i];
}
int a[m][n];
for(int i=0;i<n;i++){
   for(int j=0;j<m;j++){
      cin >> a[j][i];
   }
}

for(int i=0;i<n;i++){
   for(int j=0;j<m;j++){
      sum+=b[j]*a[j][i];
      }
      if(sum+c>0){
         ans++;
      }
      sum=0;
   }


cout << ans << endl;

////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
string N;cin >> N;
ll total = 0;

rep(i, 0, N.size()){
  
    ll a = N[i] - '0';

    total += a;

}

if(total%9 == 0)cout << "Yes";

else cout << "No";
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
  IOS int n, m, k;
  cin >> n >> m >> k;
  int a[n + 1] = {0}, b[m + 1] = {0};
  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= m; i++)
  {
    cin >> b[i];
    b[i] += b[i - 1];
  }
  int ans = 0;
  for (int i = 0; i <= n; i++)
  {
    if (a[i] > k)
      break;
    int l = 0, r = m;
    int idx = -1;
    while (l <= r)
    {
      int mid = (l + r) / 2;
      if (k - a[i] == b[mid])
      {
        idx = mid;
        break;
      }
      else if (k - a[i] > b[mid])
      {
        l = mid + 1;
      }
      else
      {
        idx = mid - 1;
        r = mid - 1;
      }
    }
    ans = max(ans, i + idx);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6764
#include<iostream>
#include<iomanip>
#include <cmath>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int len,f=0;
    len = s.length();
    for(int i=0;(len-1)/2>i;i++){
        if(s[i]!=s[(len-3)/2-i]||s[(len-3)/2-i]!=s[(len+1)/2+i]||s[len-1-i]!=s[(len+1)/2+i]){
            f=1;
        }
    }
    if(f){
        cout << "No";
    }else{
        cout << "Yes";
    }
    
    //cout << setprecision(10) << ans; 
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,m=50000;
  cin>>n;
  vector<int> w(n);
  for(auto& i:w)cin>>i;
  for(int i=1;i<n;++i)w[i]+=w[i-1];
  for(int t=0;t<n;++t)m=min(m,abs(w[t]-(w[n-1]-w[t])));
  cout<<m;
}

Measured memory_bytes: 256
import sys
import heapq
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    M = []
    for i in range(N):
        M.append(LI())

    dp = [10**10] * (H+1)
    dp[0] = 0

    for i in range(H):
        for j in range(N):
            HP = min(H,i+M[j][0])
            dp[HP] = min(dp[HP],dp[i]+M[j][1])
    print(dp[H])

if __name__ == "__main__":
    main()


Measured memory_bytes: 40560
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int x;
bool p[maxn];
int main()
{
	cin>>x;
	for(long long i=2;i<maxn;i++)
		if(!p[i])
			for(long long j=i*i;j<maxn;j+=i)
				p[j]=true;
	for(int i=2;i<maxn;i++)
		if(!p[i]&&i>=x)
		{
			cout<<i<<endl;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
int n, m, ans;
vector<int> g[MAXn];
bool flag[MAXn];

void dfs(int v) {
	flag[v] = true;
	for (int u : g[v])
		if (!flag[u])
			dfs(u); 
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, z;
		cin >> u >> v >> z;u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 0; i < n; i++)
		if (!flag[i]) {
			dfs(i);
			ans++;
		}
	cout << ans;
}


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

const double eps = 1e-9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FORD(i,a,b) for (int i = int(b)-1; i >= (a); i--)
#define FORIT(i,c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define mp make_pair
#define pb push_back
#define mscanf(...) if(0 == scanf(__VA_ARGS__)){fprintf(stderr, "Could not parse arguments\n");}

const int MAXN = 712;
bool adjm[MAXN][MAXN];
vi forbidden[MAXN];
int color[MAXN];
bool dp[MAXN];

bool two_coloring(int n, int &s0, int & s1, int c){
    if(color[n] != -1){
        return (color[n] == c);
    }
    color[n] = c;
    ++s0;
    for(auto to: forbidden[n]){
        if(!(two_coloring(to, s1,s0,1-c)))return false;
    }
    return true;
}

int main(){
    int N,M;
    mscanf("%d%d",&N,&M);
    FOR(i,0,N)FOR(j,0,N)adjm[i][j] = (i==j);
    FOR(i,0,M){
        int a,b;
        mscanf("%d%d",&a,&b);
        --a;--b;
        adjm[a][b] = adjm[b][a] = 1;
    }
    FOR(i,0,N)forbidden[i].clear();
    FOR(i,0,N)FOR(j,0,N)if(!adjm[i][j])forbidden[i].push_back(j);
    FOR(i,0,N)color[i] = -1;
    int NH = N/2+1;
    FOR(j,0,NH)dp[j] = false;
    dp[0] = true;
    FOR(i,0,N)if(color[i] == -1){
        int s1 = 0, s2 = 0;
        if(!two_coloring(i,s1,s2,0)){
            cout << -1 << endl;
            return 0;
        }
        FORD(j,0,NH)dp[j] = (((j>=s1)?dp[j-s1]:false) | ((j>=s2)?dp[j-s2]:false));
    }
    --NH;
    while(!dp[NH])--NH;
    int nH = N - NH;
    cout << ((NH * (NH-1)) + (nH * (nH-1)))/2 << endl;
    return 0;
}


Measured memory_bytes: 3584
N = int(input())
S = list(input())
directed = [S[1:].count("W")]

for i in range(1, len(S)):
  d = directed[i - 1]
  if S[i - 1] == "E":
    d += 1
  if S[i] == "W":
    d -= 1
  directed.append(d)

print(N - max(directed) - 1)

Measured memory_bytes: 23168
#include <stdio.h>

long long int visited[55]={};
long long int graph[55][55]={};
int n,m;

int dfs(int v){
  visited[v] = 1;
  for(int v2=0;v2<n;v2++){
    if((graph[v][v2] == 1) &&
       (visited[v2] == 0)) dfs(v2);
  }
  return 0;
}

int main(){
  int a[55]={},b[55]={};
  int ans=0;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d%d",&a[i],&b[i]);
    a[i]--;b[i]--;
    graph[a[i]][b[i]] = 1;
    graph[b[i]][a[i]] = 1;
  }
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]] = 0;
    graph[b[i]][a[i]] = 0;
    for(int j=0;j<n;j++) visited[j] = 0;
    dfs(0);
    for(int j=0;j<n;j++){
      if(visited[j]==0){
        ans++;
        break;
      }
    }
    graph[a[i]][b[i]] = 1;
    graph[b[i]][a[i]] = 1;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
  
int main(){
	int n;
 	cin >> n;
    
    long long int l[n];
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i-2] + l[i-1];
    }

   	//int ans = calc(n);

  	cout << l[n] << endl;
  	
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

ret = 0
for i in range(N):
    summ = C
    for j in range(M):
        summ += A[i][j]*B[j]
    if(summ > 0):
        ret += 1
# 出力
print(ret)

Measured memory_bytes: 3064
import java.util.*;

 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int input = scanner.nextInt();
    int input2 = scanner.nextInt();
    int input3 = scanner.nextInt();
    scanner.close();
    int a = input + input2;
    int b = input2 + input3;
    int c = input3 + input;
    int alpha = Math.min(a,b);
    int beta = Math.min(alpha,c);
    System.out.println(beta);
  }
}


Measured memory_bytes: 22740
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(n):
    a.append(a[i] + A[i])

for i in range(m):
    b.append(b[i] + B[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 134172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=1000000007;
signed main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> map(n+1,vector<int>(n+1,inf));
    rep(i,m){
        int a,b,c;cin>>a>>b>>c;
        map[a][b]=c;
        map[b][a]=c;
    }
    vector<vector<int>> bufmap(map);
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                bufmap[i][j]=min(bufmap[i][j],bufmap[i][k]+bufmap[k][j]);
            }
        }
    }
    int res=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(map[i][j]!=inf&&bufmap[i][j]!=map[i][j])res++;
        }
    }
    /*rep1(i,n){
        rep1(j,n){
            cout<<bufmap[i][j]<<"\t";
        }
        cout<<endl;
    }*/
    cout<<res<<endl;
    return 0;
}

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

char s[117][117];
int flag[117][117];

int main()
{
    memset(flag,0,sizeof(flag));
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
        scanf("%s",s[i]);
//    for(int i=0;i<h;i++)
//        printf("%s\n",s[i]);
    for(int i=0;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(s[i][j]=='#'&&s[i][j-1]=='#')
            {
                flag[i][j]=flag[i][j-1]=1;
            }
        }
    }
    for(int i=1;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(s[i][j]=='#'&&s[i-1][j]=='#')
            {
                flag[i][j]=flag[i-1][j]=1;
            }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(s[i][j]=='#'&&!flag[i][j])
            {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m, q;
int lr[505][505];
int lsum[505][505];
int pq[505][505];

int main() {

	cin >> n >> m >> q;

	vi s(q), t(q);

	rep(i, m){
		int l, r;
		cin >> l >> r;
		l--;r--;
		lr[l][r]++;
	}

	rep(i, q)cin >> s[i] >> t[i];

	rep(i, n)lsum[i][i] = lr[i][i];
	rep(i, n)rep1(j, n-1)lsum[i][j] = lsum[i][j - 1] + lr[i][j];

	rep(i, n)rep(j, n)rep(k, j - i + 1)pq[i][j] += lsum[i + k][j];

	rep(i, q)cout << pq[s[i] - 1][t[i] - 1] << endl;

}

Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.length(),zero=0,one=0;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            zero++;
        }
        else one++;
    }
    cout<<n-abs(zero-one);
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b;
	string s;

	cin >> a >> s >> b;

	if (s == "+") {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;

	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll N=1e5+5;
const ll mod=1e9+7;
typedef double db;
const db pi=3.1415926535898;
char a[105];
ll k;
int main(){
    std::ios::sync_with_stdio(false);
    cin>>a;
    cin>>k;
    ll f=1;
    char c=a[0];
    ll len=strlen(a);
    for(ll i=0;i<len;i++){
        if(a[i]!=c){
            f=0;
            break;
        }
    }
    if(f){
        cout<<(len*k)/2<<endl;
    }
    else{
        ll p1,p2;
        //cout<<len<<endl;
        if(a[0]==a[len-1]){
            c=a[0];
            for(ll i=0;i<len;i++){
                if(a[i]!=c){
                    p1=i;
                    break;
                }
            }
            for(ll i=len-1;i>=0;i--){
                if(a[i]!=c){
                    p2=i;
                    break;
                }
            }
        }
        else{
            p1=0,p2=len-1;
        }
        ll s1=0;
        char cc=0;
        ll tnum=0;
        //cout<<a<<endl;
        for(ll i=p1;i<=p2;i++){
            //cout<<c<<' '<<a[i]<<' '<<tnum<<endl;
            if(cc!=a[i]){
                cc=a[i];
                s1+=(tnum/2);
                tnum=1;
            }
            else{
                tnum++;
            }
        }
        s1+=tnum/2;
        //cout<<s1<<endl;
        //cout<<p1<<' '<<p2<<endl;
        cout<<s1*k+((p1)/2)+((len-p2-1)/2)+(p1+len-p2-1)/2*(k-1)<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << (n % 2 == 0 ? n / 2 - 1 : n / 2) << endl;
  return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d.at(i);
  }
  
  int count = 1;
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  for (int i = 0; i < n; i++) {
    if (i != 0) {
      if (d.at(i) < d.at(i - 1)) {
        count++;
      }
    }
  }
  cout << count << endl;  
}
  
      
      

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;
use std::io::prelude::*;

fn main() {
    let sin = io::stdin();
    let mut lines = sin.lock().lines();

    let _n: u32 = lines.next().unwrap().unwrap().parse().unwrap();

    let mut s_a = 0;
    let mut s_b = 0;
    for l in lines {
        let ll = l.unwrap();
        let mut ws = ll.split_whitespace();
        let a = ws.next().unwrap();
        let b = ws.next().unwrap();
        if a < b {
            s_b += 3;
        } else if a > b {
            s_a += 3;
        } else {
            s_a += 1;
            s_b += 1;
        }
    }

    println!("{} {}", s_a, s_b);
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
//#define sz 2

using namespace std;

int main() {
	int a, b, c, d;
	scanf( "%d%d%d%d", &a, &b, &c, &d );
	while( a > 0 && c > 0 ) {
		c -= b;
		if( c <= 0 )
			break;
		a -= d;
	}
	if( a > 0 )
		printf( "Yes" );
	else
		printf( "No" );
	return 0;
}

Measured memory_bytes: 3828