akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int N,M,K,sum=0,res=0,A[200200];
string S;
int main(){
    cout << fixed << setprecision(18);
    cin>>S;
    cout<<S;
    if(S[S.size()-1]=='s'){cout<<"es"<<endl;}
    else{cout<<"s"<<endl;}
}



Measured memory_bytes: 3612
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int dignum(ll n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int main(){

  ll N;
  cin >> N;

  int ans = dignum(N); // 最大の桁数を求めて億

  for (ll A = 1; A*A <= N; A++) {
    if(N%A != 0) continue;
    const ll B = N/A;

    const int cur = max(dignum(A), dignum(B)); // 関数F（AとBの大きい桁数を保存する)

    ans = min(ans, cur); // 最小の値を求める
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
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 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    rep(i, 0, K) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;



int main() {
    ll n,h; cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(b.rbegin(), b.rend());
    sort(a.rbegin(), a.rend());

    ll ans = (h + (a[0] - 1)) / a[0];
    ll sumattack = 0;
    rep(i, n) {
        sumattack += b[i];
        ll tmpans = (h - sumattack + (a[0] - 1)) / a[0];
        if(tmpans < 0) tmpans = i+1;
        else tmpans += i+1;
        chmin(ans, tmpans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int r = 0;
		for (char c : s.toCharArray()) {
			r += c - '0';
		}
		System.out.println(r%9==0?"Yes":"No");
	}
}


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

#define INF 0x3f3f3f3f

int main(void)
{
    int a, b, n;
    long long ans = 0;
    int minn = INF;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;

        ans += a;
        if (a > b)
        {
            minn = min(minn, b);
        }
    }
    if (minn != INF)
    {
        cout << (ans - minn) << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}


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

#define LLINF 1100000000000000000

using namespace std;

typedef long long ll;

ll sepChoco(ll A, ll B)
{
  ll ret = LLINF;
  for (int i = 1; i <= (A + 1) / 2; i++) {
    // 縦
    ll a1 = A / 3;
    ll a2 = (A - a1) / 2;
    ll a3 = A - a1 - a2;
    ret = min(max({a1, a2, a3}) * B - min({a1, a2, a3}) * B, ret);

    // 横
    ll s1 = i * B;
    ll s2 = (A - i) * (B / 2);
    ll s3 = (A - i) * (B - B / 2);
    ret = min(max({s1, s2, s3}) - min({s1, s2, s3}), ret);
  }
  
  return ret;
}

int main()
{
  ll H, W;
  cin >> H >> W;
  cout << min(sepChoco(H, W), sepChoco(W, H)) << endl;

  return 0;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

int main()
{
	while (true)
	{
		string txt;
		cin >> txt;

		if (txt == "0") break;

		int sum = 0;
		for (int i = 0; i < txt.length(); i++)
		{
			char c = txt[i];
			int n = c - '0';
			sum += n;
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b;
  cin>>a>>b;
  if(1<=a&&a<=9&&1<=b&&b<=9)
    cout<<a*b;
  else
    cout<<-1;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
hikaku = a[0]
i = k
t=0
while i <= n - 1:
    if hikaku < a[i]:
        print("Yes")
    else:
        print("No")
    t += 1
    i+=1
    hikaku=a[t]

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

const int MOD = 1000000007;
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];

template <typename T>

void print(T x)
{
	std::cout << x << '\n';
}

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;
}

signed main(void) {
	int N,K;
	cin >> N >>K;
	COMinit();
	rep1(i, K + 1) {
		cout << COM(N - K + 1, i)*COM(K - 1, i - 1) % MOD << endl;
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int

	fmt.Scanf("%d %d", &n, &k)
	a := make([]int, n)
	var d int
	c := make([]int, n)
	count := 0

	for i := 0; i < k; i++ {
		fmt.Scanf("%d", &d)
		for j := 0; j < d; j++ {
			fmt.Scanf("%d", &a[j])
		}
		for j := 0; j < d; j++ {
			c[a[j]-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		if c[i] == 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 2356
#include<iostream>
using namespace std;
int main() {
	int n, k;
	cin >> n;
	cin >> k;
	if (n%k == 0) {
		cout << 0 << endl;
	}
	if (n%k != 0) {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()




int main() {

	ll H, W;
	cin >> H >> W;
	vector<vll> s(H + 2, vll(W + 2, INF));
	ll num_wall = 0;
	fori(i, 1, H + 1) {
		fori(j, 1, W + 1) {
			char tmp;
			cin >> tmp;
			if (tmp == '.') s[i][j] = -1;
			else ++num_wall;
		}
	}

	ll sx = 1, sy = 1, gx = H, gy = W;
	s[sx][sy] = 0;
	list<ll> lx, ly;
	lx.push_back(sx), ly.push_back(sy);
	ll dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, -1, 0, 1 };
	while (!lx.empty()) {
		ll cx = lx.front(), cy = ly.front();
		lx.pop_front(), ly.pop_front();

		if (cx == gx && cy == gy) {
			cout << H * W - num_wall - s[gx][gy] - 1 << endl;
			return 0;
		}

		rep(i, 4) {
			if (s[cx + dx[i]][cy + dy[i]] == -1) {
				lx.push_back(cx + dx[i]), ly.push_back(cy + dy[i]);
				s[cx + dx[i]][cy + dy[i]] = s[cx][cy] + 1;
			}
		}
		
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		String[] s = new String[2];
		
		while(true)
		{
			s[0] = scan.next();
			if(s[0].equals(".")) {break;}
			s[1] = scan.next();
			List<String> ss1 = new ArrayList<String>();
			
			List<Integer> location = new ArrayList<Integer>();
			
			int miniCounter = -1;
			
			int stringDifferences = 0;
			int numOfSs2 = 0;
			boolean done = false;
			
			for(int c = 0; c <= 1; c++)
			{
				int zure = 0;
				int start = -1;
				int end = 0;
				
//				System.out.println("STARTC " + c);
				for(int i = 0; i < s[c].length(); i++)
				{
					if(c == 1)
					{
//						System.out.println("length " + s[c].length() + ", i " + i);
					}
//					if(i >= 15) {System.out.println("now i " + i);}
					String cur = s[c].substring(i, i+1);
					
					if(cur.equals("\""))
					{
						if(start == -1)
						{
//							System.out.println("STARTQUOTE " + i);
							start = i+1;
						}
						else
						{
//							System.out.println("ENDQUOTE " + i);
							//closing quote mark
							
							end = i-1;
							if(c == 0)
							{
								location.add(i);
								ss1.add(s[c].substring(start, end+1));
							}
							else if(c == 1)
							{
								numOfSs2 += 1;
								miniCounter += 1;
								String thisOne = s[c].substring(start, end+1);
								String prevOne = "";
								if(miniCounter >= 0 && miniCounter < ss1.size())
								{
									prevOne = ss1.get(miniCounter);
								}
								
								//compare the ministrings
								if(!thisOne.equals(prevOne))
								{
									stringDifferences += 1;
									
									if(stringDifferences >= 2)
									{
										System.out.println("DIFFERENT");
										done = true;
										break;
									}
									else
									{
										zure = prevOne.length() - thisOne.length();
									}
								}
								
								
//								ss2.add(s[c].substring(start, end+1));
							}
							
							start = -1;
						}
					}
					else
					{
						//not quote
						if(start == -1)
						{
							//outside ministrings
							
							if(c == 1)
							{
								String cur1 = s[0].substring(i+zure, i+1+zure);
								String cur2 = s[1].substring(i, i+1);
								
								if(!cur1.equals(cur2))
								{
//									System.out.println(cur1 + " vs " + cur2);
									System.out.println("DIFFERENT");
									done = true;
//									stringDifferences = -1;
									break;
								}
							}
						}
					}
				}
			}
			
			if(!done)
			{
				if(numOfSs2 == ss1.size())
				{
					if(stringDifferences == 1)
					{
						System.out.println("CLOSE");
					}
					else if(stringDifferences == 0)
					{
						System.out.println("IDENTICAL");
					}
				}
				else
				{
//					System.out.println(ss1.size() + " vs " + numOfSs2);
					System.out.println("DIFFERENT");
				}
			}
		}
	}

}



Measured memory_bytes: 31380
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int T = cin.nextint;
        int min = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            int c = cin.nextint;
            int k = cin.nextint;
            if (k <= T)
            {
                chmin(ref min, c);
            }
        }
        if (min == int.MaxValue)
        {
            WriteLine("TLE");
        }
        else
        {
            WriteLine(min);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}   

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

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

int main(void) {
	ll w, h, num, i, ans;
	cin >> h >> w;
	ans = (h / 2) * w;
	if (h & 1)
		ans += (w / 2) + (w & 1);
	if (w == 1 || h == 1)
		ans = 1;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
char mp[1005][1005];
long long dp[1005][1005];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w;
    cin>>h>>w;
    rep(i,1,h){
        cin>>mp[i]+1;
    }
    dp[1][1]=1;
    rep(i,1,h)rep(j,1,w)if(mp[i][j]=='.'){
        if(mp[i-1][j]=='.')dp[i][j]+=dp[i-1][j];
        if(mp[i][j-1]=='.')dp[i][j]+=dp[i][j-1];
        //debug(i),debug(dp[i][j]);
        dp[i][j]%=(long long)1e9+7;
    }
    cout<<dp[h][w]<<endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

const int MAX = 510000;

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;
}

void func(long long N, long long M, long long K){
    COMinit();
    lli sum = 0;

    REP(i,0,N){
        REP(j,0,M){
            if(i!=0 && j!=0) sum += (2*( N-i)*(M-j)*(i+j))%MOD;
            else sum += ((N-i)*(M-j)*(i+j))%MOD;
            sum%= MOD;
        }
    }

    sum *= COM(N*M-2,K-2);
    sum %= MOD;
    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    func(N, M, K);
    return 0;
}


Measured memory_bytes: 12160
using System;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());
            var hs = new HashSet<string> {};
            for (var i = 1; i <= a; i++)
            {
                string x = Console.ReadLine();
                hs.Add(x);
            }
            Console.WriteLine(hs.Count);
        }
    }
}



Measured memory_bytes: 47360
import sys
a, b, n, = map(int, input().split())
if n < b:
    print(int(a*(n)/b)-a*int((n)/b))
    sys.exit(0)
max = 0
if b == 1:
    print(0)
    sys.exit(0)
row, up = n-b, n
while row <= up:
    mid = (row+up)//2
    if n//b == mid//b:
        up = mid-1
    elif n//b > mid//b:
        row = mid+1
if int((a*up)/b)-a*int((up)/b) > int((a*n)/b)-a*int((n)/b):
    print(int((a*up)/b)-a*int((up)/b))
else:
    print(int((a*n)/b)-a*int((n)/b))


Measured memory_bytes: 62004
let may_month = function "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10"
                                | "11" | "12" -> true | _ -> false

let may_year  _ = true

let () =
  let s = Scanf.scanf "%s\n" (fun s -> s) in
  let s1, s2 = String.sub s 0 2, String.sub s 2 2 in
  (if may_year s1 && may_month s2 && may_month s1 && may_year s2 then "AMBIGUOUS"
   else if may_year s1 && may_month s2 then "YYMM"
   else if may_month s1 && may_year s2 then "MMYY"
   else "NA"
  ) |> print_string


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const long long INF = 1LL << 60;
//const int INF = 1e9+5;
const int MOD = 1e9+7;

int H,W;
vector<string> a;

int dp[1100][1100]= {0};

void add(int &a,int b){
    a+=b;
    if(a>=MOD) a-=MOD;
}

int main(){
  cin >> H >> W;
  a.resize(H);
  for(int i=0;i<H;i++) cin >> a[i];
  dp[0][0] = 1;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i+1 < H && a[i+1][j] == '.') add(dp[i+1][j],dp[i][j]);
      if(j+1 < W && a[i][j+1] == '.') add(dp[i][j+1],dp[i][j]);
    }
  }
  cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5632
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    li = list("ixcm")
    k = [1,10,100,1000]
    d = {"i":1,"x":10,"c":100,"m":1000}
    f = ["i","x","c","m"]
    for _ in range(n):
        a,b = LS()
        s = 0
        for i in range(len(a)):
            if a[i] in li:
                a[i] = d[a[i]]
                if i > 0 and a[i-1] not in k:
                    s += a[i-1]*a[i]
                else:
                    s += a[i]
            else:
                a[i] = int(a[i])

        for i in range(len(b)):
            if b[i] in li:
                b[i] = d[b[i]]
                if i > 0 and b[i-1] not in k:
                    s += b[i-1]*b[i]
                else:
                    s += b[i]

            else:
                b[i] = int(b[i])
        ans = []
        while s != 0:
            i = int(math.log(s+0.1,10))
            m = s//k[i]
            s %= k[i]
            if m != 1:
                ans.append(m)
            ans.append(f[i])
        for i in ans:
            print(i,end="")
        print()
    return

#B
def B():
    d = [(0,1),(0,-1),(1,0),(-1,0),(1,1),(-1,-1)]
    while 1:
        t,n = LI()
        if t == n == 0:
            break
        f = defaultdict(lambda : 1)
        for i in range(n):
            x,y = LI()
            f[(x,y)] = 0
        x,y = LI()
        bfs = defaultdict(lambda : 1)
        q = deque()
        q.append((x,y,0))
        bfs[(x,y)] = 0
        ans = 1
        while q:
            x,y,turn = q.popleft()
            if turn < t:
                for dx,dy in d:
                    x2 = x+dx
                    y2 = y+dy
                    if bfs[(x2,y2)]:
                        if f[(x2,y2)]:
                            ans += 1
                            bfs[(x2,y2)] = 0
                            q.append((x2,y2,turn+1))
        print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



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

using namespace std;

int dp[1000006][3];
int a[1000006][3];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
      }
    }
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << '\n';
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>

int main()
{
	char a, b;
	std::cin >> a >> b;
	if (a == 'H') {
		if (b == 'H')
			std::cout << "H" << std::endl;
		else 
			std::cout << "D" << std::endl;
	} else {
		if (b == 'D')
			std::cout << "H" << std::endl;
		else
			std::cout << "D" << std::endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int RECT_COUNT = 0;
	public static final int Q_NUMBER = 1;


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

		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		String[] arrMemberA = bufferedReader.readLine().split(" ");
		String[] arrMemberB = bufferedReader.readLine().split(" ");

		int memberAScore = Integer.parseInt(arrMemberA[0]) + Integer.parseInt(arrMemberA[1]) + Integer.parseInt(arrMemberA[2]) + Integer.parseInt(arrMemberA[3]);
		int memberBScore = Integer.parseInt(arrMemberB[0]) + Integer.parseInt(arrMemberB[1]) + Integer.parseInt(arrMemberB[2]) + Integer.parseInt(arrMemberB[3]);

		if(memberAScore < memberBScore) System.out.println(memberBScore);
		else System.out.println(memberAScore);

	}

	public static String getStringCharAt(String str, int position) {
		return String.valueOf(str.charAt(position));
	}

	public static String[] getStringCharArr(String str) {

		String[] arrResult = new String[str.length()];

		for(int i = 0; i < str.length(); i++) arrResult[i] = getStringCharAt(str, i);

		return arrResult;
	}

	public static boolean isInnerPosition(int x1, int x2, int searchPosition) {
		return x1 <= searchPosition && searchPosition <= x2;
	}

}

Measured memory_bytes: 24352
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    k, x = LI()

    mx = x + k - 1
    mn = x - k + 1
    print(' '.join([str(c) for c in list(range(mn, mx+1))]))

solve()

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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int N, K; cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    while (K--) {
        bool terminal = true;
        REP(i, N) {
            if (A[i] < N) {
                terminal = false;
                break;
            }
        }
        if (terminal) break;

        vector<int> B(N+1);
        REP(i, N) {
            ++B[max(i - A[i], 0)];
            --B[min(i + A[i], N-1) + 1];
        }
        REP(i, N) {
            B[i+1] += B[i];
            A[i] = B[i];
        }
    }

    REP(i, N) {
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4888
#include<iostream>
using namespace std;
long long int a[200007];
int main(){
    int n;
    long long int i,j,k;
    long long int c,d,s;
    cin>>n;
    for(i=0,c=0;i<n;i++){
        cin>>a[i];
        c+=a[i];
    }
    s=-1;
    for(i=0,k=0;i<n-1;i++){
        k+=a[i];
        d=c-2*k;
        if(d<0)d=-d;
        if(d<s || s==-1)s=d;
    }
    cout<<s<<endl;
    return 0;
    
}
    
        

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

using namespace std;

int main() {
	int N, K, D[10];
	cin >> N >> K;
	for(int i=0;i<K;i++) {
		cin >> D[i];
	}
	bool ok = false;
	for(int i=0;!ok;i++, N++) {
		int n = N;
		ok = true;
		for(int j=0;n>0;j++,n/=10) {
			int u = n % 10;
			for(int k=0;k<K;k++) {
				if(D[k] == u) {
					ok = false;
					break;
				}
			}
		}
	}
	cout << N-1 << endl;
	return 0;
}


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

int n, m, x, y;
int a = -110, b = 110;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m >> x >> y;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a = max(a, t);
	}
	for(int i=0; i<m; ++i){
		int t;
		cin >> t;
		b = min(b, t);
	}
	++a;
	if(a <= b && x < a && b <= y) cout << "No War\n";
	else cout << "War\n";
}

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

using namespace std;

const int N=200;

int x[N],y[N],h[N];
int H,flag,mx,mn,n;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d%d",&x[i],&y[i],&h[i]);
	for (int i=0;i<=100;++i){
		for (int j=0;j<=100;++j){
			H=-1;flag=1;mx=0;mn=abs(x[1]-i)+abs(y[1]-j);
			for (int k=1;k<=n;++k){
//				printf("	%d %d %d:",k,h[k],H);
				if (h[k]!=0){
					if (H==-1) H=h[k]+abs(x[k]-i)+abs(y[k]-j);
					else if (h[k]!=H-abs(x[k]-i)-abs(y[k]-j)){
						flag=0;break;
					}
				}
				
				mn=min(mn,abs(x[k]-i)+abs(y[k]-j));
				mx=max(mx,abs(x[k]-i)+abs(y[k]-j));
//				printf("%d %d %d\n",mn,mx,H);
			}
			if (flag){
				if (H==-1)
					if (mn!=mx) continue;else H=mx;
//				printf("%d %d %d\n",i,j,H);
				for (int k=1;k<=n;++k)
					if (h[k]!=max(H-abs(x[k]-i)-abs(y[k]-j),0)){
						flag=0;
//						printf("%d\n",k);
						break;
					}
				if (flag){
					printf("%d %d %d\n",i,j,H);
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  if(S.at(1)==S.at(0) &&S.at(1)==S.at(2) ){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

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

int main(){ 
  int n, r;
  cin >> n >> r;
  if (n >= 10) cout << r << endl;
  else {
    cout << r + (100 * (10 - n)) << endl;
  }
  return 0;
} 

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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,t;
	bool b[26],q;
	fill(b,b+26,false);
	string a,ans={"None"};
	cin>>a;
	for (i=0;i<a.size();i++){
		t=a[i]-'0';
		t-=49;
		b[t]=true;
	}
	for (i=0;i<26;i++){
		if (b[i]==false){
			ans.clear();
			ans.push_back((char)(i+97));
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  set<int> x;
  x.emplace(1);
  x.emplace(2);
  x.emplace(3);
  x.erase(a);
  x.erase(b);
  cout << *x.begin() << endl;
}


Measured memory_bytes: 256
def gcd(a, b):
	if a < b:
	    a, b = b, a
	while a % b != 0:
	    a, b = b, a % b

	return b

N = int(input())

ans_sum = 0

for x in range(1, N+1):
	for y in range(x, N+1):
		for z in range(y, N+1):
			if x == y == z:
				ans_sum += z
			else:
				ans = gcd(x, y)
				ans = gcd(ans, z)
				if x == y or x == z or y == z:
					ans_sum += ans * 3
				else:
					ans_sum += ans * 6

print(ans_sum)

Measured memory_bytes: 9204
#include <iostream>

using namespace std;

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

    int a, b;
    cin >> a >> b;

    if (a >= 1 && b >= 1 && a <= 9 && b <= 9)
        cout << a * b << "\n";
    else
        cout << "-1\n";

    return 0;
}


Measured memory_bytes: 256
# abc174_c.py
# https://atcoder.jp/contests/abc174/tasks/abc174_c


# [開発時用] ログ関数
def lg(value):
    flag = False
    flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 1
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    # S = lines[0]
    K = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0

    tmp = 7

    if K % 5 == 0 or K % 2 == 0:
        return [-1]

    for k in range(K):

        q, mod = divmod(tmp, K)
        if mod == 0:
            return [k+1]
        tmp = mod * 10 + 7


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a1: usize,
        a2: usize,
        a3: usize,
    }
    println!("{}", if (a1 + a2 + a3 ) >= 22 {"bust"} else {"win"});
}


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

a, b = list(map(int, input().split()))
# print(a, b)

a -= 1
b -= 1
wide = 100

ans1 = [["#"]*wide for i in range(wide//2)]

ans2 = [["."]*wide for i in range(wide//2)]

index_x = 0
index_y = 0
while(a > 0):
    ans1[index_y][index_x] = "."
    index_x += 2
    if index_x == wide:
        index_x = 0
        index_y += 2
    a -= 1


index_x = 0
index_y = 1
a = b
while(a > 0):
    ans2[index_y][index_x] = "#"
    index_x += 2
    if index_x == wide:
        index_x = 0
        index_y += 2
    a -= 1

print(100, 100)
for i in ans1+ans2:
    print("".join(i))


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

int main(){
  char S[11],tmp[3];
  int i=0,min=753,num,j;
  scanf("%s",S);
  while(S[i+2]!=NULL){
    for(j=0;j<3;j++)tmp[j]=S[i+j];
    num=atoi(tmp);
    if(min>abs(num-753))min=abs(num-753);
    i++;
  }
  printf("%d\n",min);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (1000000007)

typedef struct 
{
    int no;
    int man
}stu;

stu s[MAXN];

int acsstu(const void *a, const void *b){return ((stu*)a)->man - ((stu*)b)->man;} /* 1,2,3,4.. */

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

    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        s[i].no = i+1;
        s[i].man = a;
    }
    qsort(s,n,sizeof(stu),acsstu);

    for(int i=0;i<n;i++)
    {
        printf("%d ",s[i].no);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1788
X ,K ,D = map(int,input().split())
if abs(X) > abs(K*D):
    ans = abs(X)-abs(K*D)
else:
    if (K - abs(X)//abs(D))%2 == 0:
        ans = abs(X)%abs(D)
    else:
        ans = abs(D) - abs(X)%abs(D)
print(ans)

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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

int main() {

  for(;;) {
    int n, k, m;
    std::cin >> n >> k >> m;
    if( n == 0 and k == 0 and m == 0 ) break;

    long dp[20000];
    dp[1] = 0;
    for(int i = 2; i <= n; ++i) {
      dp[i] = (dp[i - 1] + k) % i;
    }
    std::cout << (dp[n] + m - k + 1000000 * (long)n) % n + 1 << std::endl;    
  }
  
  return 0;
}

Measured memory_bytes: 3132
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parts[0].charAt(0);
var B = parts[1].charAt(0);
var C = parts[2].charAt(0);
console.log(A+B+C);

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if (d2 == 1) {
      cout << 1 << endl;
    } else{
    cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    long MOD = (long)1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int X = sc.nextInt();

        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        Arrays.sort(a, Comparator.reverseOrder());
        long[][] dp = new long[2][X + 1];
        dp[0][X] = 1;
        int sw = 0;
        for (int i = 0; i < n; i++) {
            sw = 1 - sw;
            Arrays.fill(dp[sw], 0);
            for (int x = 0; x <= X; x++) if (dp[1 - sw][x] > 0) {
                dp[sw][x % a[i]] = (dp[sw][x % a[i]] + dp[1 - sw][x]) % MOD;
                dp[sw][x] = (dp[sw][x] + dp[1 - sw][x] * (n - i - 1)) % MOD;
            }
//            debug(dp[sw]);
        }

        long sum = 0;
        for (int x = 0; x <= X; x++) {
            sum += dp[sw][x] * x;
            sum %= MOD;
        }
        System.out.println(sum);
    }

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

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


Measured memory_bytes: 24916
#include <cmath>
#include <iostream>
#include <cstdio>

const double PI = 3.14159265358979323846;

struct Vec2
{
	double x;
	double y;
	Vec2( double ix, double iy ):x(ix),y(iy){}
};

class Turtle
{
	Vec2 pos;
	double angle;
public:
	void forward(double length)
	{
		pos.x += length * cos(angle);
		pos.y += length * sin(angle);
	}
	void rotate( double angle1 )
	{
		angle -= angle1;
	}
	Vec2 GetPos(){return pos;}
	Turtle() : pos(Vec2(0.0,0.0)), angle(0.0){}
	Turtle( Vec2 v, double a ) : pos(v), angle(a){}
};

int main()
{
	Turtle turtle(Vec2(0.0,0.0),PI*0.5);
	int l,a;
	while(scanf("%d,%d",&l,&a),l||a)
	{
		turtle.forward(l);
		turtle.rotate(a*PI/180.0);
	}

	int x = static_cast<int>( turtle.GetPos().x );
	int y = static_cast<int>( turtle.GetPos().y );
	std::cout << x << '\n' << y << '\n';
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	for (auto& x : X) cin >> x;
	vector<int> ans(N*N);
	bool ok = true;
	vector<pair<int,int>> a;
	for (int i = 0; i < N; ++ i) a.push_back({X[i], i+1});
	sort(a.begin(), a.end());
	for (auto p : a) {
		int xi = p.first;
		int i = p.second;
		ans[xi-1] = i;
		int k = 0;
		for (int j = 1; j < i; ++ j) {
			for (;;) {
				if (k >= xi-1) {
					ok = false;
					goto out;
				}
				if (ans[k] == 0) break;
				++ k;
			}
			ans[k] = i;
		}
	}
	for (auto p : a) {
		int xi = p.first;
		int i = p.second;
		int k = xi;
		for (int j = i; j < N; ++ j) {
			for (;;) {
				if (k >= ans.size()) {
					ok = false;
					goto out;
				}
				if (ans[k] == 0) break;
				++ k;
			}
			ans[k] = i;
		}
	}
	out:;
	if (ok) {
		cout << "Yes" << endl;
		for (int i = 0; i < ans.size(); ++ i) {
			if (i) cout << " ";
			cout << ans[i];
		}
		cout << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, s, n) for(int i=s; i<n; i++)

using namespace std;

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

int main(){
    int N, C; cin >> N >> C;
    int D[C+1][C+1];
    int c[N+1][N+1];
    int m[3][C+1];
    memset(m, 0, sizeof(m));

    FOR(i, 1, C+1) FOR(j, 1, C+1) cin >> D[i][j];
    FOR(i, 1, N+1) FOR(j, 1, N+1){
        cin >> c[i][j];
        m[(i+j)%3][c[i][j]]++;
    }

    int mind = 1e9;
    FOR(i, 1, C+1) FOR(j, 1, C+1) FOR(k, 1, C+1){
        if (i == j || j == k || i == k) continue;
        int d = 0;
        FOR(from, 1, C+1){
            d += m[0][from] * D[from][i];
            d += m[1][from] * D[from][j];
            d += m[2][from] * D[from][k];
        }
        // cout << d << endl;
        mind = min(mind, d);
    }
    cout << mind << endl;
}


Measured memory_bytes: 1280
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;

	writeln("2018" ~ S[4..$]);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, T = map(int, input().split())
time = list(map(int, input().split()))

ans = T
for x, y in zip(time[:-1], time[1:]):
    ans += min(T, y - x)
print(ans)

Measured memory_bytes: 22004
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    while(N>0){
        if(N%10==9){
            cout1("Yes")
            return 0;
        }
        N/=10;
    }
    cout1("No")
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int p[3];
	int min=0;
	for(int i=0;i<3;++i)
		cin >> p[i];
	sort(p,p+3);
	min = p[0]+p[1];
	cout << min << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 2e5 + 7;
ll n , ans , cnt = 1;
int main(){
    TIME
    cin >> n;
    while(n > 0){
        ans += cnt;
        n /= 2;
        cnt *= 2;
    }
    cout << ans;
}
///...


Measured memory_bytes: 256
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    cout << 'A' << s[1].at(0) << 'C' << endl;
}

Measured memory_bytes: 256