akhauriyash/Code-Regression huggingface dataset:
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<"NO"; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll LL_INF=1e10;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
     string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 if(n<1000) cout<<"ABC";
 else cout<<"ABD";
 
 
 
 
 
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

//コンビネーションをmodで割った余りを産出
int64_t nCk( int64_t n, int64_t k  )
{
    int64_t ans_x = 1;
    int64_t ans_y = 1;

    for( int i = n; i > n - k; i-- )
    {
        ans_x *= i;
    }

    for( int i = 1; i <= k; i++ )
    {
        ans_y *= i;
    }

    return ans_x / ans_y;
}

int main()
{
    std::string word = "aa";
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;
    std::cin>> b;
    
    if( a < b )
    {
        for( int i = 0; i < b; i++ )
        {
            std::cout<< a;
        }
    }
    else
    {
        for( int i = 0; i < a; i++ )
        {
            std::cout<< b;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)

#define MAX_INT 2147483647

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int result; 
string field[20];
void dfs(int hx, int hy, int Lx, int Ly, int Ux, int Uy){
	int nx, ny;
	if(field[hy][hx] != '#'){
		result++;
		field[hy][hx] = '#';
		rep(i,4){
			nx = hx + dx[i]; ny = hy + dy[i];
			if (Lx <= nx && nx < Ux && Ly <= ny && ny < Uy) 
				dfs(nx, ny, Lx, Ly, Ux, Uy);
		}
	}
}
int main(){
	int W, H;
	while (1){
		cin >> W >> H;
		if (!(W and H)) break;
		result = 0;
		rep(i,H) cin >> field[i];
		rep(i,H) rep(j,W) if (field[i][j] == '@') dfs(j,i,0,0,W,H);
				cout << result << endl; 
	}
	return 0;
}

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

int main(){
    long long int a, res=0;


	cin >> a;

	res = a + a*a + a*a*a;
	
	cout << res;
 
	return 0;
}

Measured memory_bytes: 3616
import bisect

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

A.sort()
Nn = bisect.bisect_left(A, 0) # 負の数の数
Nz = bisect.bisect_left(A, 1) - Nn # 0の数
Np = N - Nn - Nz # 正の数の数
An = A[:Nn]
Ap = A[Nn+Nz:]


if Nn*Np >= K: # 答えが負の数
  left = -10**18-1 # False
  right = -1 # True
  n = Nn*Np - K # midより大きくなるのがn個より多いとmid以下のペアがK個以上にならない
  while left+1 < right:
    mid = (left+right) // 2
    i = j = 0
    c = 0
    while i < Nn and j < Np:
      if An[i]*Ap[j] > mid:
        c += 1
        j += 1
        if j >= Np:
          c += (Nn - 1 - i)*Np
      else:
        c += j
        i += 1
      if c > n:
        break
    if c > n:
      left = mid
    else:
      right = mid
  ans = right 
elif Nn*Np + Nz*(Nn+Np) + Nz*(Nz-1)//2 >= K: # 答えが0
  ans = 0
else: # 答えが正
  An = [-an for an in An][::-1]
  N = Nn*(Nn-1)//2 + Np*(Np-1)//2 # 積が正となる組合せ
  k = K - Nn*Np - Nz*(Nn+Np) - Nz*(Nz-1)//2 # 正の数の中でk番目に小さい数が答え
  n = N - k
  left = 0 # False
  right = 10**18 + 1 # True
  while left+1 < right:
    mid = (left+right) // 2
    i = 0
    j = Nn - 1
    c = 0
    while i < j:
      if An[i]*An[j] > mid:
        c += 1
        j -= 1
      else:
        c += Nn - 1 - j
        i += 1
      if i == j:
          c += (Nn-i-1)*(Nn-i-2) // 2
      if c > n:
        break
    
    if c > n:
      left = mid
    else:
      i = 0
      j = Np - 1
      while i < j:
        if Ap[i]*Ap[j] > mid:
          c += 1
          j -= 1
        else:
          c += Np - 1 - j
          i += 1
        if i == j:
            c += (Np-i-1)*(Np-i-2) // 2
        if c > n:
          break
      if c > n:
        left = mid
      else:
        right = mid
  ans = right


print(ans)

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

int main() {
  int n, k; cin >> n >> k;
  vector<int> snk(n);
  for (int i = 0; i < k; i++) {
    int d; cin >> d;
    for (int i = 0; i < d; i++) {
      int a; cin >> a;
      snk.at(~-a)++;
    }
  }
  int ans = 0;
  for (auto e : snk) if (e == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

const int MAX_N=200000;
int prime[MAX_N];
int is_prime[MAX_N+1];

int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++) is_prime[i]=1;
  is_prime[0]=is_prime[1]=0;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=0;
    }
  }
  return p;
}


int main(){
  sieve(MAX_N);
  int X; cin>>X;
  for(int i=X;i<MAX_N;i++){
    if(is_prime[i]){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
  // static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 int a = sc.nextInt();
	 int b = sc.nextInt();
	 
	 out.print(Math.max(a+b,Math.max(a-b, a*b)));
	 
	 
	
	 out.close();
		
	}
	
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793

signed main() {
    int M;
    cin >> M;
    int digit_number = 0, digit_sum = 0;
    int d, c;
    for (int i = 0; i < M; i++) {
        cin >> d >> c;
        digit_number += c;
        digit_sum += d * c;
    }
    cout << digit_number - 1 + (digit_sum - 1) / 9 << endl;
}



Measured memory_bytes: 256
while True:
    n = input()
    if n == '0': break
    m, n = map(int, n.split())
    cnt = 0
    for i in range(m, n+1):
        num = i
        while num % 5 == 0:
            num /= 5
        while num % 3 == 0:
            num /= 3
        while num % 2 == 0:
            num /= 2
        if num == 1:
            cnt += 1
    print(cnt)


Measured memory_bytes: 5596
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int NN = 220000;

int num, n, x, y, a, b, c;
ll p[NN], q[NN], r[NN], s[NN], ans; 

bool cmp(ll a, ll b){
	return a > b;
}

int main(){
	//freopen("a.in", "r", stdin);

	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	for (int i=1; i<=a; i++) scanf("%lld", &p[i]);
	for (int i=1; i<=b; i++) scanf("%lld", &q[i]);
	for (int i=1; i<=c; i++) scanf("%lld", &r[i]);

	sort(p+1, p+a+1, cmp);
	sort(q+1, q+b+1, cmp);
	sort(r+1, r+c+1, cmp);
	
	num = 0;
	for (int i=1; i<=x; i++){
		s[++num] = p[i];
		ans += p[i]; 
	}
	for (int i=1; i<=y; i++){
		s[++num] = q[i];
		ans += q[i];
	}
	sort(s+1, s+num+1);
	
	for (int i=1; i<=min(c, x+y); i++){
		if (r[i] < s[i]) break;
		else ans = ans - s[i] + r[i];
	}
	
	printf("%lld", ans);
	
	return 0;
} 

Measured memory_bytes: 6016
n, m = gets.split.map(&:to_i).sort

def fact(n)
  (1..n).inject { |x, i| x * i % 1_000_000_007 }
end

if (m - n) > 1
  puts 0
  exit
end

facted = fact(m)
if n != m
  puts facted * fact(n) % 1_000_000_007
else
  puts facted * facted * 2 % 1_000_000_007
end


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int grundy(int A, int K) {
    if (A % K == 0) { return A / K; }
    if ((A - A / K * K) % (A / K + 1) + A / K * K != A) {
        return grundy((A - A / K * K) % (A / K + 1) + A / K * K, K);
    }
    return grundy(A - A / K - 1, K);
}
int N;
int A[220], K[220];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i] >> K[i]; }
    int x = 0;
    rep(i, N) { x ^= grundy(A[i], K[i]); }
    if (x == 0) { cout << "Aoki" << endl; }
    else { cout << "Takahashi" << endl; }
}


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

value = map(int, input().split())

value = sorted(value)

while len(value) > 1:
    value_0 = (value[0] + value[1]) / 2
    new = [value_0]
    for i in range(2,len(value)):
        new.append(value[i])
    value = new

print(value[0])


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <map>

#define MAX_N (100000L)
#define STR_LEN (10L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N;
  char css[MAX_N][STR_LEN + 1];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%s", css[i]);
  }

  // sort strings
  for (long i = 0; i < N; i++) {
    sort(css[i], css[i] + STR_LEN);
    // printf("%s\n", css[i]);
  }

  // count occurence of each
  map<string, long> str_to_cnt;
  for (long i = 0; i < N; i++) {
    string str(css[i]);
    str_to_cnt[str]++;
  }

  // solve
  long ans = 0;
  for (pair<string, long> str_cnt : str_to_cnt) {
    long cnt = str_cnt.second;
    ans += cnt * (cnt - 1) / 2;
  }
  printf("%ld\n", ans);
  
  return 0;
}


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

namespace ABC152 {
    class Program {
        static void Main (string[] args) {
            int[] ab = Console.ReadLine ().Split ().Select (int.Parse).ToArray ();
            int n = ab[0] >= ab[1] ? ab[0] : ab[1];
            int m = ab[1] >= ab[0] ? ab[0] : ab[1];
            string ans = "";
            for (int i = 0; i < n; i++) {
                ans += m.ToString ();
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 文字列の入力
			String s = sc.next();
			boolean flag = false;
			String before = "";
			for (int i = 0; i < s.length(); i++) {
				String now = s.substring(i, i + 1);
				if (before.equals("")) {
					if (!now.equals("h")) {
						flag = false;
						break;
					} else {
						before = "h";
					}
				} else if (before.equals("h")) {
					if (!now.equals("i")) {
						flag = false;
						break;
					} else {
						before = "i";
						flag = true;
					}
				} else if (before.equals("i")) {
					if (!now.equals("h")) {
						flag = false;
						break;
					} else {
						before = "h";
						flag = false;
					}
				}
			}
			System.out.println(flag ? "Yes" : "No");
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string S, T;
  cin >> S >> T;
  unordered_map<char, char> mp, mpi;

  bool flg = true;
  for (int i = 0; i < S.size(); ++i) {
    char s = S[i], t = T[i];
    if (mp.count(s))
      if (mp[s] != t) flg = false;
    if (mpi.count(t))
      if (mpi[t] != s) flg = false;

    mp[s] = t, mpi[t] = s;
  }

  cout << (flg ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, a, b;
    ll k;
    multimap<int, int> ab;

    cin >> n >> k;
    rep(i, n){
        cin >> a >> b;
        ab.insert(make_pair(a, b));
    }

    ll cnt = 0;
    for(auto const& e : ab){
        if(cnt + e.second < k){
            cnt += e.second;
        }else{
            cout << e.first << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  double n;
  cin>>n;
  
  for(double i=0;i<=50000;i++){
    double m=i*1.08;
    m=(int)m;
    if(n==m){
      cout<<(int)i<<endl;
      return 0;
    }
  }

  cout<<":("<<endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

int N, M;
int A[2000], B[2000], C[2000];
int D[1000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--, B[i]--;
    C[i] = -C[i];
  }

  rep(i, N) D[i] = INF;
  D[0] = 0;
  rep(i, N-1) {
    rep(e, M) {
      int s = A[e], t = B[e], w = C[e];
      D[t] = min(D[t], D[s]+w);
    }
  }
  int p = D[N-1];
  rep(i, N-1) {
    rep(e, M) {
      int s = A[e], t = B[e], w = C[e];
      D[t] = min(D[t], D[s]+w);
    }
  }
  if (p != D[N-1]) cout << "inf\n";
  else cout << -D[N-1] << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] ary = new String[H * W];
		for (int i = 0; i < H; i++) {
			String str = sc.next();
			for (int j = 0; j < str.length(); j++) {
				ary[i * W + j] = String.valueOf(str.charAt(j));
			}
		}
		int index = 0;

		for (int i = 0; i < H + 2; i++) {
			for (int j = 0; j < W + 2; j++) {
				if (i == 0 || i == H + 1) {
					System.out.print("#");
				} else if (j == 0 || j == W + 1) {
					System.out.print("#");
				} else {
					System.out.print(ary[index]);
					index++;
				}
			}
			System.out.println("");
		}
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23508
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int[][] list = new int [101][101];
		int r = sc.nextInt();
		int c = sc.nextInt();

		for (int i =0; i < r; i++) {
			int sum = 0;
			for (int j = 0; j < c; j++) {
				list[i][j] = sc.nextInt();
				sum += list[i][j];
			}
			list[i][c] = sum;
 		}

		for (int i = 0; i <= c; i++) {
			int sum = 0;
			for (int j = 0; j < r; j++) {
				sum += list[j][i];
			}
			list[r][i] = sum;
		}

		String space = " ";
		for (int i = 0; i <= r; i++) {
			for (int j = 0; j <= c; j++) {
				if (j < c) {
					System.out.print(list[i][j] + space);
				} else {
					System.out.print(list[i][j]);
				}
			}
			System.out.println("");
		}
	}
}

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


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int d, s, t;
    cin >> d >> s >> t;
    if((s*t) >= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3528
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!
ll a[MAXN];
int main(){
	int n;
	ri(n);
	ll suma=0;
	FOR(i,0,n){
		lri(a[i]);
		suma+=a[i];
	}
	ll mini; ll suma2=0;
	FOR(i,0,n-1){
		suma2+=a[i];
		if(!i) mini=abs(suma-suma2-suma2);
		mini=min(mini,abs(suma-suma2-suma2));
	}
	printf("%lld\n",mini);
	
}


Measured memory_bytes: 1792
#include<stdio.h>

int main() {
    int A, B;
    scanf("%d %d", &A, &B);
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        printf("%d", A * B);
    } else {
        printf("-1");
    }
    return 0;
}



Measured memory_bytes: 2152
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  M m;
  REP(i,n){
    IN(x);
    m[x]++;
  }
  Vi st;
  for(auto p: m) {
    if(p.second >= 2) {
      st.pb(p.first);
    }

    if(p.second >= 4) {
      st.pb(p.first);
    }
  }
  RSORT(st);
  if(st.size()< 2) OUT(0);
  else OUT(st[0]*st[1]);
}

Measured memory_bytes: 6528
//Created by Aminul on 9/13/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        final long inf = (long) 1e15;
        int n = in.nextInt();
        long pp = -inf, pm = -inf, mp = -inf, mm = -inf, res = -inf;
        for (int i = 0; i < n; i++) {
            int x = in.nextInt(), y = in.nextInt();
            res = max(res, x + y + mm);
            res = max(res, x - y + mp);
            res = max(res, -x + y + pm);
            res = max(res, -x - y + pp);

            pp = max(pp, x + y);
            pm = max(pm, x - y);
            mp = max(mp, -x + y);
            mm = max(mm, -x - y);
        }

        pw.println(res);
        pw.close();
    }

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

Measured memory_bytes: 59548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int n,m,q;cin>>n>>m>>q;
  int train[501][501]={};
  rep(i,m){
    int l,r;cin>>l>>r;
    train[l][r]++;
  }
  rep(i,501) rep(j,500) train[i][j+1]+=train[i][j];
  rep(i,500) rep(j,501) train[i+1][j]+=train[i][j];
  rep(i,q){
    int p,r;cin>>p>>r;
    int ans=train[r][r]-train[r][p-1]-train[p-1][r]+train[p-1][p-1];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1920
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a[7],i,n,l;
	char x[101];
	for(i=1;i<7;i++){
		cin>>a[i];
	}
	cin>>x;
	l=strlen(x);
	for(i=0;i<l;i++){
		if(x[i]=='N'){
			swap(a[1],a[5]);
			swap(a[1],a[6]);
			swap(a[1],a[2]);
		}
		else if(x[i]=='S'){
			swap(a[1],a[2]);
			swap(a[1],a[6]);
			swap(a[1],a[5]);
		}
		else if(x[i]=='E'){
			swap(a[1],a[3]);
			swap(a[1],a[6]);
			swap(a[1],a[4]);
		}
		else{
			swap(a[1],a[4]);
			swap(a[1],a[6]);
			swap(a[1],a[3]);
		}
	}
	cout<<a[1]<<endl;
	return 0;
}

	


Measured memory_bytes: 3124
X = int(input())

if 400 <= X < 600:
    print('8')
elif X < 800:
    print('7')
elif X < 1000:
    print('6')
elif X < 1200:
    print('5')
elif X < 1400:
    print('4')
elif X < 1600:
    print('3')
elif X < 1800:
    print('2')
else:
    print('1')

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

int a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;

  int sum = 0;
  sum = max((a*10+b+c), sum);
  sum = max((a+b*10+c), sum);
  sum = max((a+b+c*10), sum);

  cout << sum << endl;
}


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

int main() {
    int N, M, C; cin >> N >> M >> C;
    int ans = 0;
    vector<int> B(M); for (int i = 0; i < M; i++) cin >> B[i];
    for (int i = 0; i < N; i++) {
        int k = 0;
        for (int j = 0; j < M; j++) {
            int a; cin >> a;
            k += a * B[j];
        }
        k += C;
        if (k > 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k,c=map(int,input().split())
s=input()
l=[0]*k
r=[0]*k
ld=0
rd=n-1
for i in range(k):
  j=k-1-i
  while s[ld]=='x':
    ld+=1
  while s[rd]=='x':
    rd-=1
  l[i]=ld
  ld+=1+c
  r[j]=rd
  rd-=1+c
for i in range(k):
  if l[i]==r[i]:
    print(l[i]+1)

Measured memory_bytes: 20628
#include<iostream>
using namespace std;
int mp[200];
int main()
{
	int x,n;	cin>>x>>n;
	for(int i=1;i<=n;i++){
		int k;	cin>>k;
		mp[k]=1;
	}
	for(int i=0;i<=100;i++)
	{
		if(mp[x-i]==0){
			cout<<x-i<<endl;
			break;
		}
		else if(mp[x+i]==0){
			cout<<x+i<<endl;
			break;
		}
	}
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for(int a = 0; a <= N; ++a) {
        for(int b = 0; b + a <= N; ++b) {
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if(total == Y) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    cout << res10000 << " " << res5000 << " " << res1000 << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
def get_prime_list(n):
    L = list(range(2,n+1))
    for i in range(2,int((n+1)**0.5)):
        if i not in L:
            continue
        L = [j for j in L if j <= i] + [j for j in L if j > i and j % i != 0]
    return L
L = [i for i in get_prime_list(55555) if i % 5 == 1]
print(*L[:N])

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int how_to_pay = 0;
  int total_money = 0;
  
  for (int a; a <= A; a++) {
    for (int b=0; b <= B; b++) {
      for (int c=0; c <= C; c++) {
        total_money = a * 500 + b * 100 + c * 50;
        if (total_money == X) how_to_pay++;
      }
    }
  }
  cout << how_to_pay << endl;
}        

Measured memory_bytes: 256
N,K=map(int,input().split(' '))
mod =10**9+7
dp=[0 if i==0 else pow(K//i,N,mod) for i in range(K+1)]
for i in range(K,0,-1):
    for j in range(2,K//i + 1):
        dp[i]-=dp[i*j]
ans = 0
for i in [(n)*i%mod for n,i in enumerate(dp)]:
    ans += i
    ans %=mod
print(ans)

Measured memory_bytes: 15232
def check(lst):
  c, b, a = lst
  if a >= b + c:
    return -1
  elif a ** 2 > b ** 2 + c ** 2:
    return 3
  elif a ** 2 == b ** 2 + c ** 2:
    return 1
  else:
    return 2

dic = [0] * 4
while True:
  lst = list(map(int,input().split()))
  lst.sort()
  f = check(lst)
  if f == -1:
    print(" ".join(map(str,dic)))
    break
  dic[f] += 1
  dic[0] += 1


Measured memory_bytes: 5608
#include<iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
	typedef long long ll;
	using namespace std;

	
	int main() {
	
		int i = 0,count = 0, a,b;
		cin >> a>>b;
		if (500 * a >= b) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
		

	}

Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, a[101010], mp[10101], mn, mx;
bool flag = false;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

rep(i, 1, n){
cin >> a[i];
mp[a[i]/400]++;
}


rep(i, 0, 7){
if(mp[i]){
    mn++;
    mx++;
}
}

rep(i, 8, 12){
if(mp[i]){
    mx+=mp[i];
    flag = true;
}
}

if(flag&&!mn)mn++;

cout << mn << " " << mx << endl;

return 0;}
///....


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int h[] = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            if (h[i] >= k) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 48528
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int N=sc.nextInt();
		ArrayList<Double> cc=new ArrayList<>();
		for(int i=0;i<N;i++) {
			cc.add(sc.nextDouble());
		}
		double a,b;
		while(cc.size()!=1) {
			//System.out.println(cc);
			Collections.sort(cc);
			a=cc.get(0);
			cc.remove(0);
			b=cc.get(0);
			cc.remove(0);
			cc.add((double)(a+b)/2);
		}//System.out.println(cc);
		p(cc.get(0));
		
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

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

using namespace std;

int dfs(int x,int n,int s){
  
  if(n==0){
    return (s==0);
  }
    
  if(x==10)
    return 0;
  
  int res=0;
  for(int i=x;i<=9;i++){
    res+=dfs(i+1,n-1,s-i);
  }
  return res;
}

int main(){

  int n,s;
  while(cin>>n>>s,n){
    cout<<dfs(0,n,s)<<endl;
  }
}

Measured memory_bytes: 3068
# import itertools
import math

import sys
input = sys.stdin.readline


def solve(N, D):
    return math.ceil(N / ((D * 2) + 1))

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

# P = []
# S = []
# for i in range(N):
#     pp, ss = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, D))


Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        double a = inp.nextDouble();
        double b = inp.nextDouble();
        System.out.println((int)Math.ceil(a / b));
    }
}


Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int s;
			cin >> s;
			G[i].push_back(s);
		}
	}
	vector<int>p;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			int on = 0;
			for (int k = 0; k < G[j].size(); k++) {
				if (i & (1 << G[j][k]-1)) {
					on++;
				}
			}
			if (on % 2 == p[j]) {
				sum++;
			}
		}
		if (sum == m) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 5424
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

#define f(a,x1,y1,x2,y2)(a[x2][y2]-a[x1][y2]-a[x2][y1]+a[x1][y1])

int cumv[2010][2010];
int cume[4010][4010];
char s[2010][2010];
int main(){
	int n,m,q;
	scanf("%d%d%d\n",&n,&m,&q);
	rep(i,0,n)scanf("%s\n",s[i]);
	
	rep(i,0,n)rep(j,0,m)cumv[i+1][j+1]=(s[i][j]=='1');
	rep(i,0,n)rep(j,0,m-1)cume[2*i+2][2*j+3]+=(s[i][j]=='1'&&s[i][j+1]=='1');
	rep(i,0,n-1)rep(j,0,m)cume[2*i+3][2*j+2]+=(s[i][j]=='1'&&s[i+1][j]=='1');
	
	rep(i,0,n+1)rep(j,0,m+1)cumv[i][j+1]+=cumv[i][j];
	rep(i,0,n+1)rep(j,0,m+1)cumv[i+1][j]+=cumv[i][j];

	rep(i,0,2*n+5)rep(j,0,2*m+5)cume[i][j+1]+=cume[i][j];
	rep(i,0,2*n+5)rep(j,0,2*m+5)cume[i+1][j]+=cume[i][j];
	
	while(q--){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d\n",&x1,&y1,&x2,&y2);
		--x1,--y1,--x2,--y2;
		printf("%d\n",f(cumv,x1,y1,x2+1,y2+1)-f(cume,2*x1+1,2*y1+1,2*x2+2,2*y2+2));
	}
}

Measured memory_bytes: 84224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 998244353;

int main() {
  int count[4] = {};
  rep(i, 3) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    count[a]++;
    count[b]++;
  }
  sort(count, count + 4);
  if (count[0] == 1 && count[1] == 1 && count[2] == 2 && count[3] == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  string s;
  rep(i,h){
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    long double rab;
    long double a, b, c;
    cin >> a >> b >> c;
    rab = sqrt(a*b);
    if(a+b-c+2*rab < 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
import sys
from itertools import permutations as per
input = sys.stdin.readline
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
d = [[float("inf")] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
  d[i][i] = 0
for _ in range(M):
  a, b, c = map(int, input().split())
  d[a][b] = c
  d[b][a] = c

for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      d[i][j] = min(d[i][k] + d[k][j], d[i][j])
res = float("inf")
for p in per(r, R):
  t = 0
  for i in range(R - 1):
    t += d[p[i]][p[i + 1]]
  res = min(t, res)
print(res)

Measured memory_bytes: 68828
MOD = 1000000007

A = set()

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, m = map(int, input().split())

for _ in range(m):
    a = int(input())
    A.add(a)

res = [0]*(n+1)

res[0] = 1
if 1 not in A:
    res[1] = 1

for i in range(2, n+1):
    if i in A:
        continue
    res[i] = (res[i-1] + res[i-2])%MOD

print(res[n])


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

int main(){
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  ll ans = 0;
  for(int i = 40; i >= -1; --i){ //k>=xを満たすようにした時2進数で初めてxi < kiとなるところ
    if(i != -1 && !(k&(1LL<<i))) continue; //kのi桁目は1でないと上の条件を満たせない
    ll tmp = 0;
    for(int j = 40; j >= 0; --j){ //j桁目は0と1どっちが多いか
      ll mask = 1LL<<j;
      ll num = 0;
      for(int l = 0; l < n; l++) if(a[l] & mask) num++;
      
      if(i < j){ //(2進数での)j桁目はkと同じ
        if(k & mask) tmp += mask*(n - num); //j桁目が1ならA[i]のうちj桁目が0のものとxorを考える
        else tmp += mask*num;
      }
      else if(i == j) tmp += mask*num; //xiは必ず0;
      else tmp += mask * max(num, n-num);
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;      
}

Measured memory_bytes: 4040
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));

  $x=[];
  for($i=0;$i<$n;$i++){
    if(!isset($x[$a[$i]])){
      $x[$a[$i]]=0;
    }
    $x[$a[$i]]++;
  }

  $y=[];
  // 全部の通りを求めておく
  foreach($x as $key => $value){
    $y[$key] = $value*($value-1)/2;
  }

  $all=0;
  foreach($y as $key => $value){
    $all+=$value;
  }

  for($i=0;$i<$n;$i++){
    echo $all-$y[$a[$i]]+( ($x[$a[$i]]-1)*($x[$a[$i]]-2)/2 ) . PHP_EOL;
  }



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string S; cin >> S;

	int ans = 0;
	REP(i,S.length()){
		if(S[i] == 'o') ans++;
	}
	ans += 15 - S.length();



	if(ans > 7) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;

}


Measured memory_bytes: 256