akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> cond(m);
  rep(i,m) {
    int s, c;
    cin >> s >> c;
    cond[i] = make_pair(s,c);
  }
  int beg = pow(10,n-1);
  if(beg == 1) beg = 0;

  reps(i,beg,pow(10,n)) {
    string str = to_string(i);
    int len = str.size();
    bool flag = true;
    rep(j,m) {
      int s = cond[j].fi;
      char c = (char)(cond[j].se + '0');
      if(s > len) break;
      if(str[s-1] != c) flag = false;
    }
    if(flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 10**9+7


def modcmb(n, k, mod):
    rtn = n
    for i in range(1, k):
        rtn = (rtn * ((n-i) % mod) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = (pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)) % MOD
print(ans if ans >= 0 else ans + MOD)


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  int n;
  while(cin >> n && n > 0){
    int s[n];
    int sum = 0,large = 0,small = 1000;

    rep(i,0,n){
      cin >> s[i];
      sum += s[i];
      if(large < s[i]) large = s[i];
      if(small > s[i]) small = s[i];
    }
    pout((sum -large-small)/(n-2));
  }
  return 0;
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int h,n;
    cin>>h>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    ll ans=0;
    for(int i=0; i<n; i++) ans+=a[i];
    if(ans>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s,t;

int main(){
	int k; cin >> k >> n;
	int a[n]; rep(i,n) cin >> a[i];
	int  r = 0;
	rep(i,n) r = max(r,a[i]);
	cout << max(0, r - (k - r) - 1) << "\n";
}

Measured memory_bytes: 256
use std::io::*;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    input.trim().to_string()
}

fn main() {
    let s = read_line();
    let mut count = 0;

    for c in s.chars() {
        if c == 'o' {
            count += 1;
            if count >= 8 {
                break;
            }
        }
    }

    match count + 15 - s.len() >= 8 {
        true => println!("YES"),
        false => println!("NO"),
    };
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

int X;
 cin>>X;

  vector<ll> vec(100000);
    for(int i=1;i<100;i++){
      for(int j=2;j<10;j++){
        if(pow(i,j)<=X){
        vec[i]=pow(i,j);
        }
        
      }
    }
      vsort(vec);
      vreverse(vec);
      cout<<vec[0]<<endl;

}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            
           
         

        }
    }
}

Measured memory_bytes: 5292
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char s[110],ss[55][110];
int a[55];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),ans=0,m;
	for(int i=1;i<=n;i++)scanf("%s",ss[i]+1),a[i]=read();
	scanf("%s",s+1);m=strlen(s+1);
	bool bk=false;
	for(int i=1;i<=n;i++)
	{
		if(bk==true)ans+=a[i];
		int len=strlen(ss[i]+1);
		if(len==m)
		{
			bool pd=true;
			for(int j=1;j<=len;j++)if(ss[i][j]!=s[j]){pd=false;break;}
			if(pd==true)bk=true;
		}
	}pr2(ans);
	return 0;
}

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

int main(){
  int n,m,o[100];
  string b[100];
  string l;
  int ans;

  for(;;){
    cin >> n >> m;
    if(!n && !m)break;

    ans = 0;
    for(int i=0;i<n;i++)cin >> b[i] >> o[i];
    for(int i=0;i<m;i++){
      cin >> l;
      for(int j=0;j<n;j++){
	bool f = true;
	for(int k=0;k<8;k++){
	  if(b[j][k] != '*' && b[j][k] != l[k]){
	    f = false;
	    break;
	  }
	}
	if(f){
	  ans += o[j];
	  break;
	}
      }
    }

    cout << ans << endl;
  }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

//https://beta.atcoder.jp/contests/abc112/tasks/abc112_c
public class Program_ABC112_C // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());

        var points = new int[n][];
        for (int i = 0; i < n; i++)
        {
            points[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        }

        Array.Sort(points, (a, b) => b[2].CompareTo(a[2])); //高い順にソート  先頭が高さゼロだとh1が正しい値にならないのでソートする。

        var crest = new int[3] { -1, -1, -1 };
        for (var x = 0; x < 101; x++)
        {
            var xConst = points[0][2] + Abs(x - points[0][0]);
            for (var y = 0; y < 101; y++)
            {
                var h1 = xConst + Abs(y - points[0][1]);
                var isCrest = true;
                for (int i = 1; i < n; i++)
                {
                    var h2 = points[i][2] + Abs(x - points[i][0]) + Abs(y - points[i][1]);
                    if (0 < points[i][2])
                    {
                        //座標に高さがあるということは、ピラミッドの一部なので、h1=h2が成り立つ
                        if (h1 != h2)
                        {
                            isCrest = false;
                            break;

                        }
                    }
                    else
                    {
                        //座標の高さが0の場合、ピラミッドの底辺もしくは、ピラミッドの高さとは関係ない座標の2つが考えられる。
                        //ピラミッドの底辺の場合h1=h2となり、無関係な座標で頂点を計算すると、h2<h1となる。
                        //頂点を求めるのに十分な調査が行われたことは書いてあるが、余計な調査が行われていないとは書いてない
                        //if (h1 < h2)
                        if (h2 < h1)
                        {
                            isCrest = false;
                            break;
                        }
                    }
                }

                if (isCrest)
                {
                    crest = new[] { x, y, h1 };
                    //Console.WriteLine($"{x} {y} {h1}");
                    //return;
                    break;
                }
            }

        }



        Console.WriteLine($"{crest[0]} {crest[1]} {crest[2]}");

    } // Main
}     // Class





Measured memory_bytes: 13268
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e7+1)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
    ll n,m ,k,i;
    cin>>n>>m>>k ;
    ll a[n],b[m],pre_a[n],pre_b[m];for(i=0;i<n;i++){
        cin>>a[i] ;
        if(!i) pre_a[i]=a[i];
        else pre_a[i]=a[i]+pre_a[i-1];
    }for(i=0;i<m;i++){
        cin>>b[i] ;
        if(!i) pre_b[i]=b[i];
        else pre_b[i]=b[i]+pre_b[i-1];
    }
    if(k<pre_b[0]&&k<pre_a[0]) return cout<<"0\n",0;
    ll mx=-1,cnt=0,rem=k ;
    ll up=upper_bound(pre_a,pre_a+n,k+1)-pre_a;
    mx = max(mx,up);
    for(i=0;i<m;i++){
        if(pre_b[i]>k) break;
        cnt=i+1 ;
        rem=k-pre_b[i] ;
        if(!rem) {mx=max(mx,cnt);break;}
        int upper=upper_bound(pre_a,pre_a+n,rem+1)-pre_a;
        cnt+=upper;
        mx=max(mx,cnt);
    }
    cout<<max(mx,cnt);
    
}



Measured memory_bytes: 9824
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int dat[100001];
int cnt[100001];
int gen[100001];
int main()
{
	int num,mod;
	scanf("%d%d",&num,&mod);
	for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		cnt[z%mod]++;
		dat[z]++;
	}
	for(int i=0;i<=100000;i++)
	{
		gen[i%mod]+=dat[i]/2;
	}
	int ret=0;
	for(int i=0;i+i<=mod;i++)
	{
		if(i==0||i+i==mod)ret+=cnt[i]/2;
		else
		{
			if(cnt[i]<cnt[mod-i])ret+=cnt[i]+min((cnt[mod-i]-cnt[i])/2,gen[mod-i]);
			else ret+=cnt[mod-i]+min((cnt[i]-cnt[mod-i])/2,gen[i]);
		}
	}
	printf("%d\n",ret);
}


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

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

ans = lcm(*T)
print(ans)

Measured memory_bytes: 5076
import java.util.Scanner;

public class Main {

	private final static Scanner sc = new Scanner(System.in);
    
    public static void main (String[] args) {
    	int a = sc.nextInt();
        String s = sc.next();
        if(a < 3200) {
        	System.out.println("red");
        } else {
        	System.out.println(s);
        }
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <set>
#include <queue>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <map>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppb pop_back
#define pii pair<int, int>
#define piii pair<int, pii>
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
//#define int long long
// #define ld long double
 

const int N = 2e5 + 20, mod = 1e9 + 7, inf = 2e9 + 9;
const ll INF = 1e18 + 20;

int n;
ll c, dp[N], h[N];

signed main() { __
    // freopen("a.in", "r", stdin);
    // freopen("a.out", "w", stdout);
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>h[i];
    for(int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        if(i != 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 11;
const char newl = '\n';

vl get_Prime_Fac(ll n) {
  ll num=-1;
  vl vec(MAX+1);
  for(ll i=2; n>=2; i++) {
    if(i*i==n) {num++; vec[num]=2; return vec;}
    if(i*i>n) {num++; vec[num]=1; return vec;}
    if(n%i==0) num++; 
    while(n%i==0) {n/=i; vec[num]++;}
  }
  return vec;
}

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

  ll n;
  cin >> n;
  
  vl vec = get_Prime_Fac(n);
  
  ll ans=0;
  for(ll i=0; i<=MAX+1; i++) {
    ll sum=0;
    rep2(j, INF) {
      sum += j;
      if(vec[i]>=sum) ans++;
      else break;
    }
  }
  
  cout << ans << newl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  s += "AAAAA";
  if (N > 9 || N < 5) {
    cout << "NO" << endl;
    return 0;
  } 
  int sec = 0;
  if (s[0] == 'A' && s[1] == 'K' && s[2] == 'I' && s[3] == 'H') {
    sec = 4;
  }
  else if (s[0] == 'K' && s[1] == 'I' && s[2] == 'H') {
    sec = 3;
  }
  else {
    cout << "NO" << endl;
    return 0;
  }
  
  if (s[sec] == 'A' && s[sec+1] == 'B') {
    sec += 2;
  }
  else if (s[sec] == 'B') {
    sec++;
  }
  else {
    cout << "NO" << endl;
    return 0;
  }
  
  if (s[sec] == 'A' && s[sec+1] == 'R') {
    sec += 2;
  }
  else if (s[sec] == 'R') {
    sec++;
  }
  else {
    cout << "NO" << endl;
    return 0;
  }
  
  if (N-sec == 0) {
    cout << "YES" << endl;
    return 0;
  }
  if (N-sec == 1) {
    if (s[sec] == 'A') {
      cout << "YES" << endl;
      return 0;
    }
  }
  
  cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}


/*素因数分解*/
template<typename T>
vector<int> prime_factorization(T m) {

	vector<int> div;
	int n = m;
	for (T i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			div.push_back(i);
			while (m % i == 0) {
				m /= i;
			}
		}
		
	}
	if (m != 1) {
		div.push_back(m);
	}
	return div;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	vector<int> div = prime_factorization(n);

	int M = div.size();
	
	int ans = 0;
	for (int bit = 1; bit < (1<<M); bit++)
	{
		int cnt = 0;
		int mul = 1;
		for (int j = 0; j < M; j++) {
			if ((bit >> j) & 1) {
				cnt++;
				mul *= div[j];
			}
		}

		if (cnt % 2)ans += n / mul;
		else ans -= n / mul;
	}

	ans = n - ans;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3212
w = int(raw_input())
bars = []
ans = [0 for i in range(w)]

for i in range(int(raw_input())):
	bars.append(map(int, raw_input().split(',')))

for i, j in zip(range(1, w+1),range(0,w)):
	for bar in bars:
		if bar[0] == i:
			i = bar[1]
		elif bar[1] == i:
			i = bar[0]
	ans[i-1] = j+1

for s in ans:
	print s

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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      int A;
      cin >> A;
      sum+=A*B.at(j);
    }
    if(sum>0){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
  int row, col;
  char c;
  std::cin >> row >> col;
  
  for(int i=0; i<row+2; i++){
    for(int j=0; j<col+2; j++){
      if(i==0 or j==0 or i==row+1 or j==col+1) std::cout << '#';
      else{
        std::cin >> c;
        std::cout << c;
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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












template <typename T>
class bellmanford {
private:
    struct edge {
        int to;
        T cost;
    };
    int n;
    vector<vector<edge>> g;
    vector<T> dist;
    
public:
    bellmanford(int n) : n(n), g(n){}
    
    void add_edge(int v1, int v2, T cost){
        g[v1].push_back({ v2, cost });
    }
    
    // 負の閉路があるときfalseを返す
    bool run(int s){
        dist = vector<T>(n, INF);
        dist[s] = 0;    //開始点の距離は0
        
        for (int i = 0; i < 2 * n; i++) {
            for (int v = 0; v < n; v++) {
                for (auto& e : g[v]) {
                    if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        if (i >= n - 1) {
                            // return false;
                            dist[e.to] = -INF;
                        }
                    }
                }
            }
        }
        return true;
    }
    
    T get_distance(int v){
        return dist[v];
    }
};





int main(){
    ll n, m, p;
    cin >> n >> m >> p;
    bellmanford<ll> bell(n);
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bell.add_edge(a, b, -(c - p));
    }
    bell.run(0);
    ll ans = -bell.get_distance(n - 1);
    cout << ((ans < INF)? max(ans, 0LL) : -1) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int h, w, c, ans;
int panel[8][8], done[8][8];
const int di[] = {1,0,-1,0}, dj[] = {0,1,0,-1};
inline bool in(int i, int j) { return i >= 0 and i < h and j >= 0 and j < w;}

int dfs2(int i, int j, int prev, int to, int p[8][8]){
    done[i][j] = 1;
    p[i][j] = to;
    int ret = 1;
    rep(d,4){
        int ni = i + di[d], nj = j + dj[d];
        if(in(ni,nj) and !done[ni][nj] and p[ni][nj] == prev)
            ret += dfs2(ni,nj,prev, to, p);
    }
    return ret;
}

void dfs(int turn, int pp[8][8]){
    int p[8][8];
    if(turn == 4){
        memcpy(p,pp,sizeof(p));
        memset(done, 0, sizeof(done));
        dfs2(0,0,p[0][0],c,p);
        memset(done, 0, sizeof(done));
        ans = max(ans, dfs2(0,0,p[0][0],c,p));
    }
    else {
        repi(i,1,7){
            memcpy(p,pp,sizeof(p));
            memset(done, 0, sizeof(done));
            dfs2(0,0,p[0][0],i,p);
            dfs(turn+1,p);
        }
    }
}

int solve(){
    ans = 0;
    dfs(0,panel);
    return ans;
}

bool input(){
    cin >> h >> w >> c;
    if(!h and !w and !c) return 0;
    rep(i,h)rep(j,w) cin >> panel[i][j];
    return 1;
}

int main()
{
    while(input()) cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1164
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

class Edge
{
public:
    int from,to,cost;
    Edge(int a, int b, int c) {
        from = a; to = b; cost = c;
    }
};


const int MAX = 1010;        // Set
vi dist(MAX);
vector<bool> negative(MAX);
vector<Edge> edges;


void bellmanford(int s, int N)
{
        fill(dist.begin(), dist.end(), 1LL<<60);
        dist[s] = 0;

        for (int node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                        }
                }
        }
        for (int node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                                negative[e.to] = true;
                        }
                }
        }
}

signed main()
{
        int N, M;
        cin >> N >> M;
        for (int i=0;i<M;i++){
                int a, b, c;
                cin >> a >> b >> c;
                Edge e(a, b, -c);
                edges.push_back(e);
        }

        bellmanford(1, N);
        if (negative[N]) {
                cout << "inf" << endl;
        } else {
                cout << -dist[N] << endl;
        }

}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
int n;
ll dp[200005][3];
vector<int> G[200005];
int depth[200005];
ll twopow[200005];
ll cnt[200005];
bool flag[200005];
vector<int> tp[200005];
int par[200005];
int last[200005];

struct data{
	int dep;
	ll dp[3];
	int las;
	data(){}
	data(int dd,int aa,int bb,int cc,int la){
		dep=dd;
		dp[0]=aa;
		dp[1]=bb;
		dp[2]=cc;
		las=la;
	}
};

deque<data> deq[200005];

void dfs(int v,int p){
	tp[depth[v]].push_back(v);
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=p){
			depth[G[v][i]]=depth[v]+1;
			dfs(G[v][i],v);
		}
	}
}

void send(int f,int t,int ndep){
	int v=deq[f].size();
	for(int i=0;i<v;i++){
		data d=deq[f].front();
		deq[f].pop_front();
		if(d.las!=ndep){
			d.dp[0]=(d.dp[0]+d.dp[2])%MOD;
			d.dp[2]=0;
		}
		if(deq[t][i].las!=ndep){
			deq[t][i].dp[0]=(deq[t][i].dp[0]+deq[t][i].dp[2])%MOD;
			deq[t][i].dp[2]=0;
		}
		ll tmp0=deq[t][i].dp[0]*d.dp[0]%MOD;
		ll tmp1=((deq[t][i].dp[1]*d.dp[0]%MOD)+(deq[t][i].dp[0]*d.dp[1]%MOD))%MOD;
		ll tmp2=deq[t][i].dp[1]*d.dp[1]%MOD;
		tmp2+=deq[t][i].dp[2]*d.dp[0]%MOD;
		tmp2+=deq[t][i].dp[2]*d.dp[1]%MOD;
		tmp2+=deq[t][i].dp[0]*d.dp[2]%MOD;
		tmp2+=deq[t][i].dp[1]*d.dp[2]%MOD;
		tmp2+=deq[t][i].dp[2]*d.dp[2]%MOD;
		tmp2%=MOD;
		deq[t][i].dp[0]=tmp0;
		deq[t][i].dp[1]=tmp1;
		deq[t][i].dp[2]=tmp2;
		deq[t][i].las=ndep;
	}
}

void solve(int v,int p){
	int nec=-1;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=p){
			solve(G[v][i],v);
			if(nec==-1){
				nec=par[G[v][i]];
			}else if(deq[nec].size()<deq[par[G[v][i]]].size()){
				send(nec,par[G[v][i]],depth[v]);
				nec=par[G[v][i]];
			}else{
				send(par[G[v][i]],nec,depth[v]);
			}
		}
	}
	if(nec==-1){
		par[v]=v;
		deq[v].push_front(data(depth[v],1,1,0,depth[v]));
	}else{
		par[v]=nec;
		deq[nec].push_front(data(depth[v],1,1,0,depth[v]));
	}
}

void func(int v,int p,int d){
	if(depth[v]==d){
		dp[v][0]=1;
		dp[v][1]=1;
		return;
	}
	dp[v][0]=1;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=p){
			int nv=G[v][i];
			func(G[v][i],v,d);
			ll tmp0=dp[v][0]*dp[nv][0]%MOD;
			ll tmp1=((dp[v][1]*dp[nv][0]%MOD)+(dp[v][0]*dp[nv][1]%MOD))%MOD;
			ll tmp2=dp[v][1]*dp[nv][1]%MOD;
			tmp2+=dp[v][2]*dp[nv][0]%MOD;
			tmp2+=dp[v][2]*dp[nv][1]%MOD;
			tmp2%=MOD;
			dp[v][0]=tmp0;
			dp[v][1]=tmp1;
			dp[v][2]=tmp2;
			//printf("%d %d %lld %lld\n",v,d,dp[v][0],dp[v][1]);
		}
	}
	dp[v][0]=(dp[v][0]+dp[v][2])%MOD;
	//printf("%d %d %lld %lld\n",v,d,dp[v][0],dp[v][1]);
}

int main(void){
	scanf("%d",&n);
	twopow[0]=1;
	for(int i=0;i<n;i++){
		twopow[i+1]=twopow[i]*2LL%MOD;
	}
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		G[i+1].push_back(a);
		G[a].push_back(i+1);
	}
	dfs(0,-1);
	for(int i=0;i<=n;i++){
		cnt[depth[i]]++;
	}
	solve(0,-1);
	ll ans=0;
	int v=par[0];
	for(int i=0;i<deq[v].size();i++){
		ll tmp=deq[v][i].dp[1];
		ll tmp2=deq[v][i].dep;
		tmp2=twopow[n+1-cnt[tmp2]];
		ans=(ans+tmp*tmp2%MOD)%MOD;
		//printf("%lld %lld\n",tmp,tmp2);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;

    int A[N];
    for(int i=0;i<N;i++)A[i]=0;
    
    for(int x=1;x<N;x++){
        for(int y=x+1;y<=N;y++){
            int k=min(abs(y-x),abs(X-y)+1+abs(x-Y));
            k=min(k,abs(Y-y)+1+abs(x-X));
            A[k]++;
        }
    }
    for(int i=1;i<N;i++){
        cout<<A[i]<<endl;
    }



}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll N, ans = 1;
bool np[1010];
vector<ll> pa;
ll cf[1010];

void eratosthenes(ll n) {
	np[0] = np[1] = true;
	for (ll i = 2; i*i <= n; i++) {
		if (!np[i]) {
			ll j = i + i;
			while (j <= n) {
				np[j] = true;
				j += i;
			}
		}
	}
}

void build_cf(ll n) {
	repi(i, 2, n + 1) {
		if (!np[i]) cf[i] = 1;
		else {
			ll temp = i;
			repi(j, 0, pa.size()) {
				while (temp%pa[j] == 0) {
					temp /= pa[j];
					cf[pa[j]]++;
				}
				if (temp == 1)break;
			}
		}
	}
}

int main() {
	rd(N);
	eratosthenes(N);
	repi(i, 0, N + 1) if (!np[i]) pa.push_back(i);
	build_cf(N);
	repi(i, 2, N + 1) if (cf[i] > 0) {
		ans *= (cf[i] + 1);
		ans %= MOD;
	}
	wrln(ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct timeAct{
    int Tfirst;
    int Tend;
}timeAct;

timeAct med3(timeAct x, timeAct y, timeAct z)
{
    if( x.Tend < y.Tend )
    {
    	if( y.Tend < z.Tend )
    	{
    		return y;
    	}
    	else if( z.Tend < x.Tend )
    	{
    		return x;
    	}
    	else
    	{
    		return z;
    	}
    }
    else
    {
    	if( z.Tend < y.Tend )
    	{
    		return y;
    	}
    	else if( x.Tend < z.Tend )
    	{
    		return x;
    	}
    	else
    	{
    		return z;
    	}
    }
}
 
void quickSort(timeAct *A,int p, int r)
{
    if(p < r)
    {
    	int i=p, j=r;
    	timeAct tmp, pibot = med3( A[i], A[i+(j-i)/2], A[j] );
    	while(1)
    	{
    		while( A[i].Tend < pibot.Tend ) i++;
    		while( pibot.Tend < A[j].Tend ) j--;
    		if( i >= j ) break;

    		tmp = A[i];
    		A[i] = A[j];
    		A[j] = tmp;
    		i++;
    		j--;
    	}
        quickSort(A, p, i - 1);
        quickSort(A, j + 1, r);
    }
}

int main()
{
    int i,n,cnt;
    int end=0;

    scanf("%d",&n);
    timeAct *ST = malloc(sizeof(timeAct)*n);

    /* データ読みとり */
    for( i=0 ; i<n ; i++ )
    {
        scanf("%d%d",&ST[i].Tfirst,&ST[i].Tend);
    }
//    for(i=0;i<n;i++) printf("%d %d\n",ST[i].Tfirst,ST[i].Tend);
//    printf("\n\n");

    quickSort(ST,0,n-1);

//    for(i=0;i<n;i++) printf("%d %d\n",ST[i].Tfirst,ST[i].Tend);
    end = ST[0].Tend;
    cnt = 1;
    for(i=1;i<n;i++)
    {
        if( ST[i].Tfirst > end )
        {
            cnt++;
            end = ST[i].Tend;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2564
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int x,y,i,j;
	bool ans = false;
	std::cin >> x >> y;
	for(i=0; i<=100; ++i){
		for(j=0; j<=100; ++j){
			if(i+j==x && i*4+j*2==y){
				ans = true;
			}
		}
	}
	std::cout << (ans?"Yes":"No") << std::endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define loop(a,n) for(long i=a;i<n;i++)
#define loopr(a,n) for(long i=n-1;i>=a;i--)
#define MOD 10000007
#define mod 1000000007
#define MAX 26
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
int main()
{
    fastio;
	#ifndef ONLINE_JUDGE
		freopen("input1.txt  ","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif

    ll n;
    cin>>n;
    ll x=n%10;
    if(x==2 || x== 4|| x== 5|| x==7 || x== 9)
    cout<<"hon";
    else if(x==0 ||x== 1||x== 6 ||x== 8)
    cout<<"pon";
    else if(x==3)
    cout<<"bon";
	return 0;
}


Measured memory_bytes: 3588
import java.util.*;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		long n = scan.nextLong();
		long k = scan.nextLong();
		
		if(n > k)
		{ 
			long c = n%k;
			long d = Math.abs(c - k);
			
			if(c < d)
			{
				System.out.println(c);
			}
			else
			{
				System.out.println(d);
			}
			
			
			System.out.println();
		}
		else
		{
			long a = Math.abs(n - k);
			long b = Math.abs(a - k);
			
			if(a < b)
			{
				System.out.println(a);
			}
			else
			{
				System.out.println(b);
			}
		}
			
		
		scan.close();
	}
}

Measured memory_bytes: 35816
#include<stdio.h>
int main(void){
  int a,b,c,i,j;
  scanf("%d",&i);
  for(j=0;j<i;j++){
    scanf("%d %d %d",&a,&b,&c);
    if((a*a + b*b == c*c)|| (c*c + a*a == b*b)||(b*b + c*c == a*a)){
      printf("YES\n");
    }
    else
      printf("NO\n");
  }
  return 0;
}

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

#define int long long
#define pb push_back
#define F first
#define S second

typedef pair<int, int> PII;

signed main(){
    int N;
    cin>>N;
    int dp[N][3];
    vector<int> arr[N];
    int a,b,c;
    for(int i=0; i<N; i++){
        cin>>a>>b>>c;
        arr[i].pb(a);
        arr[i].pb(b);
        arr[i].pb(c);
    }
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i=1; i<N; i++){
        //cout<<i<<endl;
        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    int res = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 9600
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
char str[26];
std::map<char,int> M ;
int N,K ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N >> K ;
  int a[N];
  REP(i,N)
    cin >> a[i] ;
  int dis= 0 ;
  int ans = 999999999 ;
  REP(i,N){
    dis = abs(a[i]) + abs(a[i+(K-1)] - a[i]);
    if(ans > dis)
      ans = dis ;
    if(i+(K) ==N)
      break;
  }
  RREP(i,N){
    dis = abs(a[i]) + abs(a[i] - a[i-(K-1)] );
    if(ans > dis)
      ans = dis ;
    if(i -(K-1)== 0)
      break;
  }
  cout << ans << endl;

  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int N=501;
int h,w,d;
char s[4]={'R','Y','G','B'};
int main(){
	scanf("%d%d%d",&h,&w,&d);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int x=(i+j+w)/d;
			int y=(i-j+w)/d;
			putchar(s[(x&1)*2+(y&1)]);
		}
		cout<<endl;
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<array>

using namespace std;

const int limit = 50;

int a[limit]; int b[limit];
int N,M;
bool visited[limit] ; bool graph[limit][limit];

void dfs(int v){
  visited[v] = true;
  for(int i = 0; i < N; i++)
   {if(graph[v][i] == false){continue;}
    else if( visited[i] == true){continue;}
    dfs(i);
   }}

int main(){
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
  
  int cnt = 0;
  
  for(int i = 0; i < M; i++){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    for( int j = 0; j < N ; j++){ visited[j] = false;}
    
    dfs(0);
    
    bool bridge = true;
    for(int k = 0; k < N; k++){
      if(visited[k] == false){bridge = false;}}
    if(!bridge){cnt++;}
     graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;}
  
  cout << cnt << endl;
  
  return 0;}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            int tmp = 0;
            for(int j = 0; j < m; j++){
                int a = sc.nextInt();
                tmp += b[j]*a;
            }
            if(tmp + c > 0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


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

struct Card {
	char suit, value;
};

void bubble(struct Card a[], int n) {
	Card hoge;
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j].value < a[j - 1].value) {
				hoge = a[j];
				a[j] = a[j - 1];
				a[j - 1] = hoge;
			}
		}
	}
}

void selection(struct Card a[], int n) {
	int minj;
	Card hoge;
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (a[j].value < a[minj].value) minj = j;
		}
		hoge = a[i];
		a[i] = a[minj];
		a[minj] = hoge;
	}
}
void print(struct Card a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0)cout << " ";
		cout << a[i].suit << a[i].value;
	}
	cout << endl;
}
bool stable(struct Card c1[], struct Card c2[], int n) {
	for (int i = 0; i < n; i++) {
		if (c1[i].suit != c2[i].suit)return false;
	}
	return true;
}

int main() {
	Card c1[40], c2[40];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c1[i].suit >> c1[i].value;
		c2[i] = c1[i];
	}
	bubble(c1, n);
	selection(c2, n);
	print(c1, n);
	cout << "Stable" << endl;
	print(c2, n);
	if (stable(c1, c2, n))cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if ((W>=(x+r)) && (H>=(y+r)) && ((x-r)>=0) && ((y-r)>=0) && (x>=0) && (y>=0))
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2060
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans1,ans2;

void solve(){
	sort(A,A+N);
	ans1 = A[N-1];
	ans2 = A[0];
	for(int i=1;i<N;i++){
		if(A[i]>ans1/2){
			if(ans1-A[i]>ans2) ans2 = A[i];
		}else{
			ans2 = max(ans2,A[i]);
		}
	}
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();
 
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

using ll = long long;

using namespace std;

bool contains(string s, char a) {
    return s[0] == a || s[1] == a;
}
void choose(char plus, char minus, map<char, int> &var, string &ans) {
    var[plus]++; var[minus]--;
    ans += plus;
}

int main() {
    int n;
    map<char, int> var;
    cin >> n >> var['A'] >> var['B'] >> var['C'];
    string s[n], ans;
    for (int i=0; i<n; i++) cin >> s[i];
    bool yes = true;
    for (int i=0; i<n; i++) {
        char x = s[i][0], y = s[i][1];
        if (var[x] < 0 || var[y] < 0 || (var[x] == 0 && var[y] == 0)) {
            yes = false;
            break;
        }
        if (var[x] == 0)                         choose(x, y, var, ans);
        else if (var[y] == 0)                    choose(y, x, var, ans);
        else if (i < n-1 && contains(s[i+1], x)) choose(x, y, var, ans);
        else                                     choose(y, x, var, ans);
    }
    if (var['A'] < 0 || var['B'] < 0 || var['C'] < 0) yes = false;
    cout << (yes ? "Yes" : "No") << '\n';
    if (yes) {
        for (auto &ai:ans) cout << ai << '\n';
    }
    return 0;
}

Measured memory_bytes: 6804
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void ABC113C_id();

#if 1
int main()
{
	ABC113C_id();

	fflush(stdout);
	return 0;
}
#endif

class ABC113C_City
{
public:
	int pref = 0;
	int year = 0;
	int x = 0;
	int myNumber = 0;
	static bool sortByPref1stYear2nd(const ABC113C_City& a, const ABC113C_City& b)
	{
		bool smaller = false;
		if (a.pref < b.pref) {
			smaller = true;
		}
		else if ((a.pref == b.pref) && (a.year < b.year)) {
			smaller = true;
		}
		return smaller;
	}

	static bool sortByYear(const ABC113C_City& a, const ABC113C_City& b)
	{
		return(a.year < b.year);
	}

	static bool sortByMyNumber(const ABC113C_City& a, const ABC113C_City& b)
	{
		return(a.myNumber < b.myNumber);
	}

};

static void ABC113C_id()
{
	int N, M;

	scanf(" %d %d", &N, &M);

	auto cities = new ABC113C_City[M + 1];
	int pref, year;
	for (int i = 0; i < M; i++) {
		scanf(" %d %d", &pref, &year);
		cities[i].pref = pref;
		cities[i].year = year;
		cities[i].myNumber = i;
	}

	std::sort(cities, cities + M, ABC113C_City::sortByPref1stYear2nd);
	int x, bfrPref = -1, prefChanged = -1;
	for (int i = 0; i < M; i++) {
		if (bfrPref != cities[i].pref) {
			x = 1;
		}
		cities[i].x = x;
		x++;

		bfrPref = cities[i].pref;
	}

	std::sort(cities, cities + M, ABC113C_City::sortByMyNumber);

	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n", cities[i].pref, cities[i].x);
	}

	delete[] cities;
}


Measured memory_bytes: 3072
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() int {
  sc.Scan()
  i, _ := strconv.Atoi(sc.Text())
  return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := next()
  k := next()
  arrP := make([]int, n, n)
  arrSum := make([]int, n-k+1, n-k+1)
  maxSum := arrSum[0]
  maxArrIndex := 0
  
  for i := 0; i < n; i++ {
    arrP[i] = next()
    if i < k {
      arrSum[0] += arrP[i]
    } else {
      arrSum[i-k+1] = arrSum[i-k] + arrP[i] - arrP[i-k]
      if arrSum[i-k+1] > maxSum {
        maxSum = arrSum[i-k+1]
        maxArrIndex = i-k+1
      }
    }
  }
  
  ex := 0.0
  for i := maxArrIndex; i < maxArrIndex+k; i++ {
    ex += float64(arrP[i]+1) / 2.0
  }
  
  fmt.Println(ex)
}

Measured memory_bytes: 4480
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#include<stdio.h>

int main() {
	int a[256], b[256];
	int i, j, k, l, x, y;
	char s[100000];
	fgets(s, 100000, stdin);
	for (i = 0;i < 256;i++) { a[i] = 0;b[i] = -1; }
	l = strlen(s);
	for (i = 0;i < l;i++) {
		a[s[i]]++;
		if (b[s[i]] == -1) {
			b[s[i]] = i;
		}
		if (i - b[s[i]] > (a[s[i]]-1) * 2) {
			a[s[i]] = 1;
			b[s[i]] = i;
		}
		if (i - b[s[i]] +1 < a[s[i]]*2 && i-b[s[i]]+1>=2) {
			printf("%d %d\n", b[s[i]]+1, i+1);
			return 0;
		}
	}

	printf("-1 -1\n");

	return 0;
}

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

#define pb push_back
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

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

const int Maxn = 10 + 10;
const int Maxk = 15;
const ll Inf = LONG_LONG_MAX >> 2;
const int Log = 20;
const ll Mod = 10321;
const ll Del = 10321;

ll pw[Maxn];
int num(char c){
	return c - '0';
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	pw[0] = 1;
	for(int i = 1; i < Maxn; i++) pw[i] = 10 * pw[i - 1];
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i; j < n - 1; j++){
			ans += ( num(s[i]) * pw[j - i] * (1ll << (n - 1 - (j - i + 1))) );
		}
		ans += (num(s[i]) * pw[n - 1 - i] * (1ll << (i)));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int maxn=10+2;
int n;
int main(){
	scanf("%d",&n);
	int all=1,res=1;
	for (int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		all*=3;
		if (!(a&1)) res<<=1;
	}
	printf("%d",all-res);
	return 0;
}

Measured memory_bytes: 256