akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static int N, K;
        static List<List<int>> G = new List<List<int>>();
        static bool[] seen;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var p = cin.SplitRead();
            N = p[0];
            K = p[1];
            if (N == 1)
            {
                Console.WriteLine(K);
                return;
            }
            for (var i = 0; i < N; i++) G.Add(new List<int>());
            seen = new bool[N];
            for(var i = 0; i < N - 1; i++)
            {
                var input = cin.SplitRead();
                int a = input[0] - 1;
                int b = input[1] - 1;

                G[a].Add(b);
                G[b].Add(a);
            }
            var cl = new long[N];


            Dfs(0, cl);
            cl[0] = K;
            long ans = K;
            for(var i = 1; i < N; i++)
            {
                ans = (ans * Max(0, cl[i])) % MOD;
            }
            //for (var i = 0; i < N; i++) Console.WriteLine($"{i} {cl[i]}");

            Console.WriteLine(ans);


        }
        static void Dfs(int v, long[] cl)
        {
            seen[v] = true;
            int r = v == 0 ? 1 : 2;
            for(var i = 0; i < G[v].Count(); i++)
            {
                if (seen[G[v][i]]) { continue; }
                cl[G[v][i]] = K - r;
                r++;
                Dfs(G[v][i], cl);
            }
        }

        
    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 35840
#include<iostream>
#include<cstdio>
int a[200001];
int f[200001];
int cnt,l,r,mid,ans,maxn=0;
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		f[a[i]]=f[a[i]-1]+1;
		maxn=max(maxn,f[a[i]]);
	}
	cout<<n-maxn;
}

Measured memory_bytes: 1792
// ABC 156-B
// 2020.2.23 bal4u

#include <stdio.h>

int main()
{
	int N, K, ans;

	scanf("%d%d", &N, &K);
	ans = 0;
	while (N) N /= K, ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

struct UnionFind {
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x) {
    return -r[root(x)];
  }
};

int main()
{
  int ans = -1;
  int n , m;
  cin >> n >> m;
  UnionFind tree(n);
  int check[n] = {0};
  REP(i,0,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.unite(a,b);
  }

  REP(i,0,n){
    int a = tree.root(i);
    if(check[a]==0)ans++;
    check[a] = 1;
  }


  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
  long long int a,b,c,d,e,f,g[110],h[110];
  cin >>a;
  d =10000;
  for(int i=1;i<a;i++){
    
   b =(i%10+i%100/10+i%1000/100+i%10000/1000+i%100000/10000);
    c =((a-i)%10+(a-i)%100/10+(a-i)%1000/100+(a-i)%10000/1000+(a-i)%100000/10000);
    
    d =min(d,(b+c));
  }
  
  cout << d << endl;
}
    
   


Measured memory_bytes: 256
/**************************************
 * Au: Hany01
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define x first
#define y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
    register char c_; register int _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

int n, x, a[105], cnt;

int main()
{
#ifdef hany01
    File("a");
#endif

    n = read(), x = read();
    For(i, 1, n) a[i] = read();
    sort(a + 1, a + 1 + n);
    For(i, 1, n) {
        if (x >= a[i]) ++ cnt, x -= a[i];
        else break;
    }
    if (x && cnt == n) -- cnt;
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
const val mod = 998244353

fun main() {
	val (n,s) = readLine()!!.split(" ").map {it.toInt()}
	var a = readLine()!!.split(" ").map {it.toInt()}

	val dp = Array(n+1) {LongArray(s+1) {0}}
	dp[0][0] = 1

	for((i,a) in a.withIndex()) {
		for(j in 0..s) {
			dp[i+1][j] = (dp[i+1][j]+dp[i][j]*2)%mod
			if(j+a<=s)
				dp[i+1][j+a] = (dp[i+1][j+a]+dp[i][j])%mod
		}
	}
	println(dp[n][s])
}


Measured memory_bytes: 108080
#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> stack, seq;
	int n;

	while(cin >> n){
		if(cin.eof()){
			break;
		}
		if(n == 0){
			seq.push_back(stack.back());
			stack.pop_back();
		}else{
			stack.push_back(n);
		}
	}
	for(int& n : seq){
		cout << n << endl;
	}
}

Measured memory_bytes: 3044
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] c = new int[4][4];
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        c[i][j] = sc.nextInt();
      }
    }
    int a1 = 0;
    int b1 = c[1][1] - a1;
    int b2 = c[1][2] - a1;
    int b3 = c[1][3] - a1;
    
    boolean ans = 
         c[2][1] - b1 == c[2][2] - b2
      && c[2][2] - b2 == c[2][3] - b3
      && c[3][1] - b1 == c[3][2] - b2
      && c[3][2] - b2 == c[3][3] - b3;
    
    System.out.println(ans ? "Yes" : "No");
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const int mod = 200003;//1e9 + 7;//786433;//998244353;//1e9 + 7
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int g[100005];
vector <int> Adj[100005];

void DFS(int node, int p = -1)
{
	for(auto x : Adj[node])
	{
		if(x == p)
		{
			continue;
		}
		DFS(x, node);
		g[node] ^= (g[x] + 1);
	}
}

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	DFS(1);
	if(g[1])
	{
		cout << "Alice";
	}
	else
	{
		cout << "Bob";
	}
}

Measured memory_bytes: 17240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<string,ll>q;
	ll ans=0;
	for(ll i=0;i<n;i++){
		string t;
		cin>>t;
		q[t]++;
		ans=max(q[t],ans);
	}
	for(auto itr=q.begin();itr!=q.end();itr++){
		ll num=itr->second;
		if(num==ans){
			cout << itr->first<<endl;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 19192
def check v
	return true if (v&v).count == 1
	return true if v[0]+1==v[1] && v[1]+1==v[2]
	return false
end

gets.to_i.times{
	an=gets.split(" ").map{|e|e.to_i}
	ac=gets.split(" ")
	count=0
	c=[[],[],[]]
	ac.each_with_index{|v,i|
		c[0].concat [an[i]] if v == "R"
		c[1].concat [an[i]] if v == "G"
		c[2].concat [an[i]] if v == "B"
	}
	max=0
	3.times{|i|
		maxCount=0
		c[i].permutation{|pset|
			count=0
			(pset.length/3).times{|t|
				break if !check(pset[3*t..3*t+2])
				count += 1
			}
			maxCount = count if maxCount < count
			break if max+maxCount >= 3
		}
		max += maxCount
	}
	p 1 if max >= 3
	p 0 if max < 3
}

Measured memory_bytes: 6124
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    s = read(str)

    sum_east = [0] * (n + 1)
    sum_west = [0] * (n + 1)
    for i in range(1, n + 1):
        sum_east[i] = (1 if s[i - 1] == "E" else 0) + sum_east[i - 1]
        sum_west[i] = i - sum_east[i]
    dprint(repr(sum_east))
    dprint(repr(sum_west))
    
    ans = 1_000_000
    for i in range(n):
        turn_from_west = sum_west[i]
        turn_from_east = sum_east[n] - sum_east[i + 1]
        if ans > turn_from_east + turn_from_west:
            ans = turn_from_east + turn_from_west
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 36832
while 1:
    n, k = map(int, raw_input().split())
    if n == k == 0:
        break
    C = [int(raw_input()) for i in xrange(k)]
    C.sort()
    if C[0] == 0:
        C[0] = -2
    cnt = 1; ans = 0
    I = []
    for i in xrange(1, k):
        if C[i-1]+1 == C[i]:
            cnt += 1
        else:
            I.append((C[i-cnt], C[i-1], cnt))
            ans = max(ans, cnt)
            cnt = 1
    I.append((C[k-cnt], C[k-1], cnt))
    if C[0] < 0:
        for j in xrange(1, len(I)):
            if I[j-1][1]+2 == I[j][0]:
                ans = max(ans, I[j-1][2]+I[j][2]+1)
    print ans

Measured memory_bytes: 10008
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long sum = 0;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 1; j <= s.Length - i; j++)
                {
                    int mul = 1;
                    int l = i == 0 ? 0 : i - 1;
                    mul *= (int)Math.Pow(2, l);
                    int r = (i + j) == s.Length ? (i + j) : (i + j + 1);
                    mul *= (int)Math.Pow(2, s.Length - r);
                    sum += long.Parse(s.Substring(i, j)) * mul;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 2776
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		int waitt[10000] = {0};
		int i, j;
		long sum = 0;
		
		for (i = 0; i < n; i++) scanf("%d", waitt + i);
		sort(waitt, waitt + n);
		for (i = 0; i < n - 1; i++){
			for (j = 0; j <= i; j++){
				sum += waitt[j];
			}
		}
		printf("%ld\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1084
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
  int count=0;
  string s;
  string t;
  cin >> s;
  cin >> t;
  for(int i=0; s[i] != '\0'; i++){
    if(s[i] != t[i]){
      count ++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3828
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)

	counter := make([]int, 26)

	for y := 0; y < h; y++ {
		a := getNextString(scanner)
		for x := 0; x < w; x++ {
			counter[a[x]-'a']++
		}
	}

	modshair := make([]int, 4)

	for i := 0; i < 26; i++ {
		modshair[counter[i]%4] += counter[i] % 4
	}

	ans := "Yes"
	if h%2 == 0 && w%2 == 0 {
		if modshair[1]+modshair[2]+modshair[3] > 0 {
			ans = "No"
		}
	} else if h%2 == 0 {
		if modshair[1]+modshair[3] > 0 {
			ans = "No"
		}
		if modshair[1]+modshair[2]+modshair[3] > h {
			ans = "No"
		}
	} else if w%2 == 0 {
		if modshair[1]+modshair[3] > 0 {
			ans = "No"
		}
		if modshair[1]+modshair[2]+modshair[3] > w {
			ans = "No"
		}
	} else {
		if modshair[1]+modshair[3] > 1 {
			ans = "No"
		}
		if modshair[1]+modshair[2]+modshair[3] >= w+h {
			ans = "No"
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, m;cin>>n>>m;

  int result = 0;
  if(n>0)result += n*(n-1)/2;
  if(m>0)result += m*(m-1)/2;
  cout<<result<<endl;
  return 0;
}

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

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	ios::sync_with_stdio(false),cin.tie(0);
	string s,t;
	cin >> s >> t;
	int sum = 0;
	for(int i=0;i<(int) t.size();i++){
		if(t[i]!=s[i]) sum++;
	}
	cout << sum << endl;

	return 0;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;

  ll biscuits = 1, yen = 0;
  if (B - 1 <= A) {
    biscuits += K;
  } else {
    while (0 < K) {
      if (0 < yen) {
        biscuits += B, yen--;
      } else if (1 < K && A <= biscuits) {
        biscuits -= A, yen++;
      } else {
        biscuits++;
      }
      K--;
    }
  }

  cout << biscuits << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int N,M,Q;
int a[200000];
int ans[200000];
vector<int> tonari[200000];
vector<int> dp,arr;

void dfs(int n,int par){
    int s=dp.size();
    arr.push_back(a[n]);
    dp.push_back(MOD);

    auto it = lower_bound(dp.begin(),dp.end(),arr[s]);
    int moto=*it;
    *it = arr[s];
    int place=it-dp.begin();
    ans[n]=lower_bound(dp.begin(),dp.end(),MOD)-dp.begin();
    //cout<<n<<"ok"<<endl;
    for(auto i:tonari[n]){
        if(i==par) continue;
        dfs(i,n);
    }
    //cout<<n<<"out"<<endl;

    arr.pop_back();
    dp.pop_back();
    dp[place]=moto;
}

void solve(int ca){
    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    int u,v;
    for (int i = 0; i < N - 1; ++i) {
        cin>>u>>v; --u; --v;
        tonari[u].push_back(v);
        tonari[v].push_back(u);
    }
    dfs(0,-1);
    for (int i = 0; i < N; ++i) {
        printf("%d\n",ans[i]);
    }
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 31684
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
//#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);

inline int rd(){
  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;
}

void out(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) out(a / 10);
  putchar(a % 10 + '0');
}
int H, W, M;
const int maxn = 3e5+10;
int h[maxn], w[maxn];
int hh[maxn], ww[maxn];
//int aa[maxn], bb[maxn];
vector<int> hpos, wpos;
//struct node{
//  int x, y;
//  node(int X, int Y){
//    x = X, y = Y;
//  }
//  bool friend operator<(const node &a, const node &b) {
//    return a.x == b.x && a.y == b.y;
//  }
//};
//map<node, int> mp;
set<int> st[maxn];
signed main(){
//int main() {
  H = rd(), W = rd(), M = rd();
  int maxh = 0, maxw = 0;  
  for (int i = 1; i <= M; i++) {
    h[i] = rd(), hh[h[i]]++, w[i] = rd(), ww[w[i]]++;
//    printf("h[i] = %lld w[i] = %lld\n",h[i],w[i]);
//    mp[node(h[i],w[i])] = 1;
    st[h[i]].insert(w[i]);
    maxh = max(maxh, hh[h[i]]);
    maxw = max(maxw, ww[w[i]]);
  }
  for (int i = 1; i <= H; i++) {
    if (hh[i] == maxh) hpos.push_back(i);
  }
  for (int i = 1; i <= W; i++) {
    if (ww[i] == maxw) wpos.push_back(i);
  }
//  cout << mp[node(1,5)] << " debug\n";
  int ans = 0;
  int flag = 0;
  for (auto i : hpos) {
    if (flag) break;
    for (auto j : wpos) {
//      cout << "i = " << i << " j = " << j << '\n';
//      printf("hh[i] = %lld ww[j] = %lld\n",hh[i],ww[j]);
//      printf("mp[node(%lld,%lld)] = ",i,j);
//      cout << mp[node(i,j)] << '\n';
      int now = hh[i] + ww[j] - (st[i].find(j) != st[i].end());
      if (ans <= now) {
        ans = now;
      } else {
        flag = 1;
        break;
      }
//      ans = max(ans, hh[i] + ww[j]);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 49032
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] dp = new int[30];
        dp[0] = 1;
        dp[1] = 2;
        dp[2] = 4;
        for (int i = 3; i < 30; i++) {
            dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
        }
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
           System.out.println((dp[n-1]-1)/3650+1);
        }
    }

}


Measured memory_bytes: 26360
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in<ll>(),A=in<ll>(),B=in<ll>();
	ll C=N/(A+B);
	ll D=N%(A+B);
	ll E=(D>=A)?A:D;
	out(C*A+E);
	return 0;
}


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

int main(){
  ll k, a, b;
  cin >> k >> a >> b;
  if(b-a <= 2 || a - 1 >= k) {
    cout << k + 1 << endl;
    return 0;
  } 
  ll ans = a + (k-a+1)/2*(b-a);
  if((k-a+1) % 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=405;
int a,b;
int main(){
    cin>>a>>b;
    if(abs(a-b)%2) cout<<"IMPOSSIBLE\n";
    else
        cout<<min(a,b)+abs(a-b)/2<<'\n';
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();

	if (s[n - 1] == '1') {
		cout << -1; return 0;
	}
	if (s[0] == '0') {
		cout << -1; return 0;
	}
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[n - 2 - i]) {
			cout << -1; return 0;
		}
	}
	int now = 1;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == '1') {
			cout << now << " " << i + 2 << endl;
			now = i + 2;
		}
		else {
			cout << now << " " << i + 2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
N, X, M = map(int, input().split())

rec = []
s = set()
rec.append(X)
s.add(X)
r = X
idx = -1
idx1 = -1
for i in range(N+1):
    r = (r**2)%M
    if(r not in s):
        rec.append(r)
        s.add(r)
    else:
        rec.append(r)
        idx = i+1
        break
    
for i in range(len(rec)):
    if(rec[i] == rec[idx]):
        idx1 = i
        break

if(idx == -1 or idx1 == -1):
    print(sum(rec[:N]))
elif(idx1 != idx):       
    ans = sum(rec[:idx1])
    ans += sum(rec[idx1:idx])*((N-idx1)//(idx-idx1))+sum(rec[idx1:(idx1+(N-idx1)%(idx-idx1))])
    print(ans)
else:
    ans = sum(rec[:idx1])
    ans += rec[idx]*(N-idx1)
    print(ans)

Measured memory_bytes: 13224
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")


Measured memory_bytes: 3064
n=int(input())
a=[0 for i in range(n)]
for i in range(n):
    a[i]=int(input())
if sum(a)%10!=0:
    print(sum(a))
else:
    a.sort()
    for i in range(n):
        if (sum(a)-a[i])%10!=0:
            print(sum(a)-a[i])
            exit()
    print(0) 




Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main ()
{
    string n;
    cin >> n;

    int sum = 0;

    for (int i = 0; i < (int) n.size(); ++i)
    {
        sum += (int)(n[i] - '0');
    }

    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 3716
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int NA = N * A;

		if (NA > B) {
			System.out.println(B);
		}else{
			System.out.println(NA);
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
    string S,T;
    cin>>S;
    T="aaaaaaa";
    long long n,i,j,k;
    n=S.length();
    for(i=0;i<8;i++){
        k=0;
        for(j=0;j<i;j++){
            T[k]=S[j];
            k++;
        }
        for(j=n-(7-i);j<n;j++){
            T[k]=S[j];
            k++;
        }
        if(T=="keyence"){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


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

int main(){
  ll n, W;
  cin >> n >> W;
  vector<ll> bag[4];
  ll w, w_min, v;
  for(int i = 0; i < n; i++){
    cin >> w >> v;
    if(i == 0) w_min = w;
    bag[w - w_min].push_back(v);
  }
  for(int i = 0; i < 4; i++){
    sort(bag[i].begin(), bag[i].end());
    bag[i].push_back(0);
    reverse(bag[i].begin(), bag[i].end());
    for(int j = 1; j < bag[i].size(); j++) bag[i][j] += bag[i][j-1];
  }
  ll res = -1e9;
  for(ll i = 0; i < bag[0].size(); i++){
    for(ll j = 0; j < bag[1].size(); j++){
      for(ll k = 0; k < bag[2].size(); k++){
        for(ll l = 0; l < bag[3].size(); l++){
          ll sum = i * w_min + j * (w_min + 1) + k * (w_min + 2) + l * (w_min + 3);
          if(sum <= W) res = max(res, bag[0][i] + bag[1][j] + bag[2][k] + bag[3][l]); 
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main()
{

    long long  n,m,q;
    cin >> n >> m >> q;
    long long v = n * (long long )(min(q,m-1)/m);
    long long c = (long long )(n*min(m-1,q))/m;
    cout<<c-v;
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int month, day, n;
	int md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30,  31, 30};

	while (1) {
		scanf("%d %d", &month, &day);

		if (month == 0) break;
		n = 0;

		for (int i = 0; i < month; i++) {
			n += md[i];
		}
		n += day;

		switch (n%7) {
			case 0: printf("Wednesday\n"); break;
			case 1: printf("Thursday\n"); break;
			case 2: printf("Friday\n"); break;
			case 3: printf("Saturday\n"); break;
			case 4: printf("Sunday\n"); break;
			case 5: printf("Monday\n"); break;
			case 6: printf("Tuesday\n"); break;
		}
	}

	return 0;
}

Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  string c1, c2;
  cin >> c1 >> c2;
  if(c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>


using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using qii=deque<pii>;


int solve(vvi&a, qii&q)
{
	int ax[]={ 1, 0,-1, 0};
	int ay[]={ 0, 1, 0,-1};
	int h=a.size();
	int w=a[0].size();
	int ret=0;

	while(q.size())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop_front();

		for(int i=0;i<4;i++)
		{
			int nx=x+ax[i];
			int ny=y+ay[i];
			if(nx<0 || w<=nx) continue;
			if(ny<0 || h<=ny) continue;
			if(a[ny][nx]>=0) continue;

			ret=a[ny][nx]=a[y][x]+1;
			q.push_back(make_pair(nx, ny));
		}
	}
	return ret;
}


int main(void)
{
	int h, w;

	while(scanf("%d%d\n", &h, &w)==2)
	{
		vvi a(h);
		qii q;
		for(int i=0;i<h;i++)
		{
			char s[1000+2];

			a[i].resize(w, -1);
			scanf("%1000[#.]\n", s);
			for(int j=0;j<w;j++)
			{
				if(s[j]=='#')
				{
					a[i][j]=0;
					q.push_back(make_pair(j, i));
				}
			}
		}
		printf("%d\n", solve(a, q));
	}
	return 0;
}


Measured memory_bytes: 12432
#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<vector<int>> s(100030);
int seen[100050] = {};
int seen2[100050] = {};
int seen3[100050] = {};
int main() {
	int n, u, v;
	cin >> n >> u >> v;
	for (int i = 0; i < n-1; i++) {
		int x, y;
		cin >> x >> y;
		s[x].push_back(y);
		s[y].push_back(x);
	}
	int ans = 0;
	queue<int> q;
	q.push(u);
	seen[u] = 1;
	while (q.size()) {
		int a = q.front();
		q.pop();
		for (auto j : s[a]) {
			if (seen[j] == 0) {
				q.push(j);
				seen[j] = seen[a] + 1;
			}
		}
	}
	q.push(v);
	seen2[v] = 1;
	while (q.size()) {
		int a = q.front();
		q.pop();
		for (auto j : s[a]) {
			if (seen2[j] == 0) {
				q.push(j);
				seen2[j] = seen2[a] + 1;
			}
		}
	}

	q.push(u);
	seen3[u] = 1;
	while (q.size()) {
		int a = q.front();
		q.pop();
		for (auto j : s[a]) {
			if (seen[j] < seen2[j] && seen3[j] == 0) {
				q.push(j);
				seen3[j] = 1;
			}
		}
	}
	for (int i = 0; i <= n; i++) {
		if (seen3[i] == 1) {
			ans = max(ans, seen2[i] - 2);
		}
	}
	cout << ans;
}


Measured memory_bytes: 7040
import java.io.*;
import java.util.*;

public class Main {

    public void solve() {
        int n = in.nextInt();;
        int[]a = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (a[a[i] - 1] == i + 1) {
                ans++;
            }
        }
        out.println(ans / 2);

    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

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

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

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


Measured memory_bytes: 22372
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	char c[h][w];
	for (int i = 0; i < h; i++) scanf("%s", c[i]);
	vector<int> cnth(h), cntv(w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '#') cnth[i]++, cntv[j]++;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (cnth[i] != 0 and cntv[j] != 0) printf("%c", c[i][j]);
		}
		if (cnth[i] != 0) printf("\n");
	}
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> A(n);
		vector<int> B(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> A[i] >> B[i];
		}
		int pointA = 0;
		int pointB = 0;
		for(int i = 0; i < n; ++i)
		{
			if(A[i] > B[i])
			{
				pointA += A[i] + B[i];
			}
			else if(A[i] < B[i])
			{
				pointB += A[i] + B[i];
			}
			else
			{
				pointA += A[i];
				pointB += A[i];
			}
		}
		cout << pointA << " " << pointB << endl;
	}
}

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

Measured memory_bytes: 0
import collections

def main():
    N = input()
    LList = list(map(int, input().split()))
    LListLen = len(LList)

    answer = 0

    if(LListLen < 3):
        print(answer)
        return

    for i in range(LListLen):
        a_key = LList[i]
        
        for j in range(i, LListLen):
            b_key = LList[j]

            if a_key == b_key:
                continue

            for k in range(j, LListLen):
                c_key = LList[k]

                if (a_key == c_key) or (b_key == c_key):
                    continue
                
                if (a_key + b_key > c_key) and (b_key + c_key > a_key) and (c_key + a_key > b_key):
                    answer = answer + 1

    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9452
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int X,t;
	cin >>X>>t;
	
	cout <<max(0,X-t)<< endl;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];
			var nums = S.Select(x => int.Parse(x.ToString())).ToArray();

			var seconds = new long[11];
			var tens = new long[11];

			var length = nums.Count();
			for (int i = 0; i < length; i++) {
				if (i==0) {
					seconds[i] = 1;
				}
				else {
					seconds[i] = seconds[i - 1] * 2;
				}

			}

			for (int i = 0; i < length; i++) {
				if (i == 0) {
					tens[i] = 1;
				}
				else {
					tens[i] = tens[i - 1] * 10;
				}

			}

			var sums = new List<long>();
			for (int i = 0; i < length; i++) {

				var left = seconds[i];
				var num = nums[i];
				long sum = 0;
				for (int j = i; j < length; j++) {
					var right = Math.Max(0, length - j - 2);
					sum += left * num * seconds[right] * tens[j-i];
				}
				sums.Add(sum);
			}

			//答えの出力
			var ans = sums.Sum();
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

int n;
int a[1000];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int cnt=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			for(int k=1;k<=j;k++)
			{
				if(i!=j && j!=k && i!=k && a[i]!=a[j] && a[j]!=a[k]  && a[i]!=a[k])
				{
					int x=a[i],y=a[j],z=a[k];
					if(x+y>z && x+z>y && y+z>x) cnt++;
				}
			}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,k;
  cin>>n>>k;
  combination comb(n+10);
  for(int i = 1;i<=k;i++){
    mint blue = comb(k-1,i-1);
    mint red = comb(n-k+1,i);
    mint ans = blue*red;
    cout<<ans.x<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
# 解説AC
from collections import deque

def check(d:int):
    """ K回以下の操作でAがdの倍数となるか判定する """
    mod = deque(sorted([a % d for a in A if (a % d != 0)]))

    ans = 0
    while mod:
        modmin = mod.popleft() # modの最小値

        # modmin -> 0 を考える
        ans += modmin
        while modmin:
            if not mod: return False # modmin -> 0 にできない
            modmax = mod.pop()
            sub = d - modmax # modmax -> d にする操作回数
            if sub <= modmin:
                # modmin -> 0 の方が操作回数が必要な場合
                modmin -= sub
            else:
                # modmax -> d の方が操作回数が必要な場合
                # (※ modmax > d となることはない)
                modmax += modmin
                if modmax % d != 0:
                    mod.append(modmax)
                modmin = 0
    
    return True if (ans <= K) else False
    

def make_divisors(n:int):
    """ nの約数を昇順で列挙 """
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

###############################
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

sumA_divisors = make_divisors(sum(A))

ans = 0
for d in sumA_divisors:
    if check(d):
        ans = d

print(ans)

Measured memory_bytes: 3436
import sys

if __name__=='__main__':
  lines = [int(x.strip()) for x in sys.stdin.readlines() if x != '' and x != '\n']
  n = lines[0]
for i in xrange(n):
  a, b  = lines[2*i+1], lines[2*i+2]
  if len(str(a+b)) > 80:
    print 'overflow'
  else:
    print a+b

Measured memory_bytes: 4240
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, Y: int, x: "List[int]", y: "List[int]"):
    maxx = max(x)
    maxx = max(maxx,X)
    miny = min(y)
    miny = min(miny,Y)

    if maxx < miny:
        print("No War")
    else:
        print("War")


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    y = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, X, Y, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3592
import sys
from io import StringIO
import unittest

def resolve():
    x, = input().split()
    if x=='0':
        print(1)
    else:
        print(0)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long N;
	long len;
	bool flag = true;
	string A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N-1;i++) {
		len = A[i].size();
		if (A[i][len-1] == A[i+1][0]);
		else flag = false;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			if (A[i] == A[j]) {
				flag = false;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    vector<int> c(n);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        cin>>c[i];

    }
    rep(i,n){
        if(v[i]-c[i]>0) ans+=(v[i]-c[i]);
    }
    cout<<ans<<endl;


    return 0;
}

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

void insertionSort(int A[],int n,int g,int& cnt){
  for(int i = g; i<n;i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[],int n){
  int cnt = 0;
  int m = max(int(log(double(n)) / double(log(3))) , 1);
  //int m = int(sqrt(double(n))) ;
  cout << m << endl;
  //cout << m << "m" << endl;

  vector<int> G(m,1);
  for(int i=1;i<m;i++)G.at(i) = 1 + 3*G.at(i-1);
  reverse(G.begin(),G.end());
  rep(i,m-1) cout << G[i] << " ";
  cout << G[m-1] << endl;
  //cout << G[m-1] << "G" << endl;
  
  for(int i = 0; i<m; i++) insertionSort(A, n, G[i], cnt);
  cout << cnt << endl;
  
  rep(i,n) cout << A[i] << endl;

}

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i,N)cin >> a[i];

  shellSort(a,N);
  
}


Measured memory_bytes: 7240
#include <iostream>
using namespace std;
#define rep(i,n)for(int i = 0 ; i < n ; i++)
#define MAX 20

int main()
{
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;

    int x[MAX], y[MAX];
    rep(i,n){
      cin >> x[i] >> y[i];
    }
    for(int i = n ; i < MAX ; i++){
      x[i] = y[i] = -1;
    }

    int m;
    cin >> m;
    int rpx = 10, rpy = 10;

    for(int i = 0 ; i < m ; i++){
      char d;
      int l;
      cin >> d >> l;
      int dx = 0, dy = 0;
      if(d == 'N'){
	dy = 1;
      }else if(d == 'E'){
	dx = 1;
      }else if(d == 'S'){
	dy = -1;
      }else if(d == 'W'){
	dx = -1;
      }

      for(int i = 0 ; i < l ; i++){
	rpx += dx;
	rpy += dy;
	for(int j = 0 ; j < n ; j++){
	  if(rpx == x[j] && rpy == y[j]){
	    x[j] = y[j] = -1;
	  }
	}
      }
    }
      bool tf = true;
      rep(i,n){
	if(x[i] != -1){
	  cout << "No" << '\n';
	  tf = false;
	  break;
	}
      }
      if(tf){
	cout << "Yes" << '\n';
      }
  }
}

Measured memory_bytes: 1120