akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n, m, x;
int a[20][20], b[20];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif

  scanf("%d%d%d", &n, &m, &x);

  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  int ans = -1;
  for (int rt = 0; rt < (1 << n); rt++) {
    vector<int> c(m, 0);
    int cost = 0;
    for (int i = 0; i < n; i++) {
      if ((rt >> i) & 1) {
        cost += b[i];
        for (int j = 0; j < m; j++) {
          c[j] += a[i][j];
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (c[j] < x) {
        flag = false;
      }
    }
    if (flag) {
      if (ans == -1 || cost < ans) {
        ans = cost;
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b;
	cin>>a>>b;
	int save=b;
	while(b > 0)
	{
		a*=10;
		b/=10;
	}
	a+=save;
	for(int c=1;c*c<=a;c++)
	{
		if(c*c==a)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct event {
    ll t, type, val;
    bool operator<(const event &a) {
        return t < a.t;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<event> eves;
    vector<int> D(q);
    for(int i = 0; i < n; i++) {
        ll s,t,x;
        cin >> s >> t >> x;
        eves.push_back({s-x, 1, x});
        eves.push_back({t-x, -1, x});
    }
    for(int i = 0; i < q; i++) {
        cin >> D[i];
    }
    sort(eves.begin(), eves.end());

    int k = 0;
    multiset<ll> s; 
    for(int i = 0; i < q; i++) {
        ll now = D[i];
        while(k < eves.size() && eves[k].t <= now) {
            if(eves[k].type == 1) {
                s.insert(eves[k].val);
            }else{
                s.erase(s.find(eves[k].val));
            }
            k++;
        }

        if(s.empty()) {
            cout << -1 << endl;
        }else {
            cout << *s.begin() << endl;
        }
    }
    
}


Measured memory_bytes: 22248
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s1,s2,s3;
cin>>s1>>s2>>s3;
string s = "";
s+=s1[0];
s+=s2[0];
s+=s3[0];
transform(s.begin(), s.end(), s.begin(), ::toupper);
cout<<s<<endl;
//system("pause");
return 0;
}

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

int main() {
	int n,taro,hanako;
	cin >> n;
	string a[n][2];
	for(int i = 0; i < n; i++){
		cin >> a[i][0];
		cin >> a[i][1];
	}
	for(int i = 0; i < n; i++){
		if(a[i][0] > a[i][1]){
			taro += 3;
		}else if(a[i][0] < a[i][1]){
			hanako += 3;
		}else{
			taro++;
			hanako++;
		}
	}
	cout << taro << " " << hanako << endl;
	return 0;
}


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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  ll r, d, x;
  cin >> r >> d >> x;
  rep(i,10){
    x = r * x -d;
    cout << x << endl;
  }
}




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

using namespace std;

#define PROBLEM "C"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define MAXN 100005
#define LL long long

LL l[MAXN];
LL r[MAXN];
LL dp[MAXN];

int main()
{
	#ifdef DBG
	freopen(PROBLEM TESTC ".in", "r", stdin);
	freopen(PROBLEM ".out", "w", stdout);
	#endif

	int n;
	while(~scanf("%d",&n))
	{
		int tmp;
		memset(dp, 0, sizeof(dp));
		memset(r,0,sizeof(r));
		memset(l,0,sizeof(l));
		for (int i = 0; i < n; i++)
		{
			scanf("%d",&tmp);
			dp[i] = tmp;
		}
		//算前綴
		l[0] = dp[0];
		for(int i = 1; i < n; i++)
			l[i] = __gcd(l[i-1], dp[i]);
		
		//算後綴
		r[n-1] = dp[n-1];
		for(int i = n-2; i >= 0; i--)
			r[i] = __gcd(r[i+1], dp[i]);

		LL ans = 1;
		//嘗試砍每一個
		for(int i = 1; i < n-1; i++)
			ans = max(__gcd(r[i+1],l[i-1]), ans);
		
		//砍頭砍尾
		ans = max(ans, max(r[1],l[n-2]));


		cout << ans << '\n';

		
	}
	
	

	return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long res = n;
  for (long long v = 0; v < n; ++v) {
    res += v * (n - v + 1);
  }
  for (int i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    tie(u, v) = minmax({u, v});
    res -= u * (n - v + 1);
  }
  cout << res << '\n';
}


Measured memory_bytes: 3648
from collections import defaultdict
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    cumsum = [0]*(n+1)
    for i in range(1,n+1):
        cumsum[i] = cumsum[i-1]+ls[i-1]
    cnt = defaultdict(int)
    for i in cumsum:
        cnt[i] +=1
    ans = 0
    for i in cnt.values():
        if i==1:
            continue
        ans += int(i*(i-1)/2)
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 112976
N,D=map(int,input().split())
XY=[]
for i in range(N):
    ab=list(map(int,input().split()))
    XY.append(ab)

ans=0
D2=D*D
for i in range(N):
    dist=XY[i][0]**2+XY[i][1]**2
    if dist<=D2:
        ans+=1

print(ans)

Measured memory_bytes: 45456
#include<iostream>
using namespace std;
int main(){
	
	int n,i,s,h,j;
	char a,x[4][14]={false};
	cin>>n;

	for(i=0;i<n;i++)
	{
		cin>>a>>s;
		if(a=='S')x[0][s]=true;
		if(a=='H')x[1][s]=true;
		if(a=='C')x[2][s]=true;
		if(a=='D')x[3][s]=true;

	}
	for(h=0;h<4;h++)
	{
		for(j=0;j<13;j++)
		{
			if(x[h][j+1]==false){
 
				if(h==0){cout<<"S "<<j+1<<endl;}
				if(h==1){cout<<"H "<<j+1<<endl;}
				if(h==2){cout<<"C "<<j+1<<endl;}
				if(h==3){cout<<"D "<<j+1<<endl;}      
			}
		}
	}
			
			
			


		
	


	return 0;
}


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 1200000;
vector < int > v[N];
int used[N], l[N], t[N], p[N];
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += t[r];
	return result;
}

void inc (int i, int delta)
{
	for (; i < N ; i = (i | (i+1)))
		t[i] += delta;
}
int solve(string s){
    int n = s.length();
    for (int i = 0; i < N; i++){
        t[i] = 0;
        used[i] = 0;
        v[i].clear();
        l[i] = 0;
    }
    for (int i = 0; i < n; i++){
        v[s[i] - 'a'].pb(i);
    }
    int k = 0;
    for (int i = 0; i < 26; i++) if (v[i].size() % 2) k++;
    if (k != n % 2){
        cout << -1;
        exit(0);
    }
    int lb = 0;
    int rb = n - 1;
    int ans = 0;
    for (int i = 0; i < n; i++){
        int x = s[i] - 'a';
        if (v[x].size() > 2 * l[x] + 1){
            p[lb] = i;
            p[rb] = v[x][v[x].size() - l[x] - 1];
            lb++;
            rb--;
            l[x]++;
        } else
        if (2 * l[x] + 1 == v[x].size()){
            p[n / 2] = i;
            l[x]++;
        }
    }
    for (int i = 0; i < n; i++){
        ans += i - sum(p[i]);
        inc(p[i], 1);
    }
    return ans;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int n = s.length();
    int res = solve(s);
    cout << res;
}


Measured memory_bytes: 61708
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int n = in();
	vector<ll>a(n), b(n);
	ll a_sum = 0, b_sum = 0;
	REP(i, n) {
		int foo = in();
		a[i] = foo;
		a_sum += foo;
	}
	REP(i, n) {
		int foo = in();
		b[i] = foo;
		b_sum += foo;
	}
	if (a_sum < b_sum) {
		cout << -1 << endl;
	} else {
		vector<ll>kajo;
		ll fusoku_sum = 0, fusoku_cnt = 0;
		REP(i, n) {
			if (a[i] > b[i]) {
				kajo.push_back(a[i] - b[i]);
			} else if (a[i] < b[i]) {
				fusoku_sum += b[i] - a[i];
				++fusoku_cnt;
			}
		}
		if (fusoku_sum == 0) {
			cout << 0 << endl;
		} else {
			sort(ALL(kajo), greater<ll>());
			REP(i, kajo.size()) {
				fusoku_sum -= kajo[i];
				if (fusoku_sum <= 0) {
					cout << fusoku_cnt + i + 1 << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 2428
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int a,b;
	int ans;
	
	//データの読み込み
	scanf("%d %d",&a,&b);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	if(a!=2&&b!=2){
		printf("Yes");
	}else{
		printf("No");
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
const int inf=1<<30;

#include<string>
int main()
{
	string s;
	cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC")<<endl;
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String p = sc.next();

		String word_chain = s + s;
		int judge = 0;

		judge = word_chain.indexOf(p);
		if (judge != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}



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

using namespace std;

int main()
{
    int N;
    string S;
    cin>>N>>S;
    int len=S.length();
        if(len>N){
        string substring = S.substr(0,N);
        cout<<substring<<"...";
    }
    else{
        cout<<S;
    }

    return 0;
}

Measured memory_bytes: 3552
import re
n = int(input())
memo = [{} for _ in range(n)]
MOD = 10**9 + 7

def check(string):
    if re.match(".*(AGC|GAC|ACG|A.?GC|AG.?C).*", string):
        return False
    return True


def dfs(string="", depth=0): # return ok count
    if depth == n:
        return 1

    if string in memo[depth]:
        return memo[depth][string]

    cnt = 0
    for i in "AGCT":
        next_string = string + i
        if check(next_string):
            cnt += dfs(string[-3:] + i, depth + 1)
            cnt %= MOD
    memo[depth][string] = cnt
    return cnt

print(dfs())


Measured memory_bytes: 6292
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

fun main(args: Array<String>) {
  val (n, k, q) = fastReadInts(3)
  val xs = fastReadInts(n)

  var ans = Int.MAX_VALUE

  // Define here for performance.
  val forbidden = BooleanArray(n)
  for (l in xs) {
    forbidden.fill(false)

    for (i in 0 until n) {
      if (xs[i] < l) {
        forbidden[i] = true
      }
    }

    val candidates = mutableListOf<Int>()
    var s = 0
    while (s < n) {
      if (forbidden[s]) {
        s++
      } else {
        var t = s
        while (t + 1 < n && !forbidden[t + 1]) {
          t++
        }
        // xs[s]..xs[t] is a valid range.
        val segmentLength = t - s + 1
        if (segmentLength >= k) {
          val segmentValues = mutableListOf<Int>()
          for (i in s..t) {
            segmentValues.add(xs[i])
          }
          segmentValues.sort()
          for (i in 0 until segmentLength - k + 1) {
            candidates.add(segmentValues[i])
          }
        }
        s = t + 1
      }
    }

    if (candidates.size < q) continue

    candidates.sort()
    val u = candidates[q - 1]
    ans = Math.min(u - l, ans)
  }
  println(ans)
}


Measured memory_bytes: 106140
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

ll f(ll n){
    if(n%2==0) return n/2;
    else return 3*n+1;
}

ll a[1000000]={0};
bool btn[1000000]={false};

int main(){
    ll s;
    cin >> s;
    for(ll i=1;i<1000000;i++){
        if(i==1) a[i]=s;
        else a[i] = f(a[i-1]);
        if(btn[a[i]]){
            cout << i << endl;
            return 0;
        }
        btn[a[i]]=true;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n;
pii a[N];

int main(){
    readi(n);
    lp(i,1,n) read2i(a[i].f, a[i].s);

    sort(a+1, a+1+n);

    ll ans = a[1].f + a[n].s;
    lp(i,2,n){
        ans += min(a[i].f - a[i-1].f, a[i-1].s - a[i].s);
    }
    cout <<ans;
}

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


Measured memory_bytes: 1024
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var AB = input[0].map(e => parseInt(e, 10));
  var ans = AB[0] * AB[1];
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29692
N, K = map(int, input().split())
R, S, P = map(int, input().split())
t = list(input())

cnt = [0] * N
for i in range(N):
    if t[i] == 'r':
        cnt[i] = P
    elif t[i] == 's':
        cnt[i] = R
    else:
        cnt[i] = S

for i in range(K, N):
    if t[i] == t[i-K]:
        t[i] = 'A'
        cnt[i] = 0
ans = sum(cnt)
print(ans)

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

int main(int argc, char **argv)
{
	ll a, b, c;
	cin >> a >> b >> c;
	ll a_{a}, b_{b}, c_{c};

	for (ll i = 0;;++i)
	{
		if (i != 0)
		{
			if (a == a_ && b == b_ && c == c_)
			{
				std::cout << -1 << std::endl;
				return 0;
			}
		}

		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
		{
			std::cout << i << std::endl;
			return 0;
		}

		ll tmp_a = a;
		ll tmp_b = b;
		ll tmp_c = c;
		a = (tmp_b + tmp_c) / 2;
		b = (tmp_a + tmp_c) / 2;
		c = (tmp_a + tmp_b) / 2;
	}
}

Measured memory_bytes: 256
hoge = input().split()
K = int(hoge[0])
N = int(hoge[1])
A_list = list(map(int,input().split()))

kankaku = []
for i in range(len(A_list) - 1):
  kankaku.append(A_list[i+1] - A_list[i])
kankaku.append(A_list[0] - A_list[-1] + K)

_kankaku_max = max(kankaku)
print(K - _kankaku_max)

Measured memory_bytes: 26444
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std; 



int main(){
    long long a; cin >> a;
    
    long long ans=1;
    long long mi;
    vector<int> q(a);
    
    for (long long i=0;i<a;i++){
        cin >> q[i];
        if (i==0){
            mi=q[0];
        }
        else{
            if (mi>=q[i]) {
                mi=q[i];
                ans++;
            }
        }
    }
    cout << ans << "\n";
}

    

  


Measured memory_bytes: 1024
S=input()

year=int(S[0:4])
month=int(S[5:7])
if year<2019:
  print('Heisei')
elif year>2019:
  print('TBD')
else:
  if month<=4:
    print('Heisei')
  elif month>4:
    print('TBD')

Measured memory_bytes: 3060
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
	public static int[] m;

	public static void Main()
	{
		var m0 = new int[] { 1, 20, 18, 20, 20, 13 };
		m = new int[6];
		m[0] = m0[0];
		for (int i = 1; i < 6; i++) m[i] = m[i - 1] * m0[i];
		Array.Reverse(m);

		while (true)
		{
			string[] s = Console.ReadLine().Trim().Split('.');
			if (s[0] == "#") break;
			var a = new List<int>();
			for (int i = 0; i < s.Length; i++) a.Add(int.Parse(s[i]));
			var ans = getAns(a);
			Console.WriteLine(string.Join(".", ans));
		}
	}

	static List<long> getAns(List<int> a)
	{
		var ans = new List<long>();

		if (a.Count() == 3)
		{
			var diff = GetDays(a[0], a[1], a[2]) - 734857;
			var answ = new long[6];
			for (int i = 0; i < 6; i++)
			{
				answ[i] = diff / m[i];
				if (i > 0) ans.Add(answ[i]);
				diff -= answ[i] * m[i];
			}
		}
		else
		{
			var diff = 0;
			for (int i = 0; i < 5; i++)
				diff += a[i] * m[i + 1];
			var dt = new DateTime(2012, 12, 21).AddDays(diff);
			ans.Add(dt.Year);
			ans.Add(dt.Month);
			ans.Add(dt.Day);
		}
		return ans;
	}
	static long GetDays(long y, int m, int d)
	{
		if (m <= 2)
		{
			--y;
			m += 12;
		}
		long dy = 365 * (y - 1);
		long c = y / 100;
		long dl = (y >> 2) - c + (c >> 2);
		int dm = (m * 979 - 1033) >> 5;
		return dy + dl + dm + d - 1;
	}
}



Measured memory_bytes: 20428
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int r;
int main()
{
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 764
//
//AtCoder Beginner Contest 146
//A - Can't Wait for Holiday
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <functional>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    const string week[8] = {"SUN","MON","TUE","WED","THU","FRI","SAT","SUN"};

    string s;

    cin >> s;

    int ans = 0;

    REP(i, 8){
        if (week[i] == s){
            ans = 7-i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
Sprime = input() # S'の入力
T = input() # Tの入力
S = [] # Sの候補をlistで管理
if len(Sprime) < len(T): # S'の文字列長がTの文字列長よりも短い場合はそもそもSが存在しえない
    print("UNRESTORABLE")
    exit()
for i in range(len(Sprime) - len(T) + 1): # 左からTを入れられるか見ていく
    flag = 0 # 文字が一致しえないことのflagを初期化
    if Sprime[i] == T[0] or Sprime[i] == "?":
        for j in range(len(T)):
            if Sprime[i + j] != T[j] and Sprime[i + j] != "?": # 一致しえない場合
                flag += 1
                break
        if flag != 1:
            S.append(Sprime[0 : i].replace("?", "a") + T + Sprime[i + len(T) :].replace("?", "a")) # 辞書順最小を求めるので?は全てaにする
S.sort() # Sの候補をさらに辞書順に並べる
if S == []: # Sの候補が無い場合 "UNRESTORABLE" を出力
    print("UNRESTORABLE")
else: # Sの候補のうち辞書順最小のものを出力
    print(S[0])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)  for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define rep(i, n)	  for(int i = 0; i < (n); ++i)
#define all(c)		  begin(c), end(c)
#define rall(c)		  rbegin(c), rend(c)
#define SZ(a)		  ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;

int main() {
	string s;
	cin >> s;
	char   mae;
	char   usiro;
	int	   i, j;
	int	   count = 0;
	i = 0;
	j = SZ(s) - 1;

	while(i < j) {
		mae	  = s[i];
		usiro = s[j];
		if(mae == usiro) {
			i++;
			j--;
		}
		else if(mae == 'x' and usiro == 'x') {
			i++;
			j--;
		}
		else if(mae == 'x') {
			count++;
			i++;
		}
		else if(usiro == 'x') {
			count++;
			j--;
		}
		else {
			count = -1;
			break;
		}
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
ll cnt[200001];
int a[200001];
int main() {
	std::ios::sync_with_stdio(false);
	char s[10];
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
# for i in range(n-1):
#     for j in range(i+1,n):
#         ans += A[i]*A[j]
#         ans %= mod
sum = 0
for i in A:
    sum += i

ans = sum * sum
for j in A:
    ans -= j * j
ans //= 2    
ans %= mod
# ans = 0
# for i in range(n):
#     ans += A[i] * (sum-A[i])
#     ans %= mod
# ans //= 2
print(ans)



Measured memory_bytes: 30952
#include<iostream>
#include<algorithm>
int n;
int a[200000];
long long sum, s;
long long ans = 1000000000000000, b;
int main() {
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
		sum += a[i];
	}
	for (int j = 0; j < n-1; j++) {
		s += a[j];
		ans = std::min(ans, std::abs(sum-s*2));
	}
	std::cout << ans << "\n";
	system("pause");
	return 0;
}

Measured memory_bytes: 1272
using System;

class Aoj
{
	public static void Main()
	{
		// var inputs = Console.ReadLine().Split(' ');

		var dataCount = int.Parse(Console.ReadLine());
		var datas = new int[dataCount];
		var max = int.MinValue;
		var chkLimitValue = int.MaxValue;

		for (int i = 0; i < dataCount; i++)
		{
			datas[i] = int.Parse(Console.ReadLine());
		}

		// datas.Dump();

		for (int i = 0; i < dataCount - 1; i++)
		{
			if (datas[i] >= chkLimitValue)
			{
				continue;
			}
			
			chkLimitValue = datas[i];
			for (int j = i + 1; j < dataCount; j++)
			{
				max = Math.Max(datas[j] - datas[i], max);
			}
		}

		Console.WriteLine(max);
	}
}

// Define other methods and classes here

Measured memory_bytes: 10768
#include <stdio.h>

#define MAP(a, b, c, d, e, f) {a-1, b-1, c-1, d-1, e-1, f-1}
#define _ 0
int dice_map[6][6] = {
	MAP(_, 3, 5, 2, 4, _),
	MAP(4, _, 1, 6, _, 3),
	MAP(2, 6, _, _, 1, 5),
	MAP(5, 1, _, _, 6, 2),
	MAP(3, _, 6, 1, _, 4),
	MAP(_, 4, 2, 5, 3, _),
#undef MAP
#undef _
};

int
main(void)
{
	int label_to_face[101];
	int face_to_label[6];
	int q;

	for (int i = 0; i < 6; i++) {
		int a;
		scanf("%d", &a);
		face_to_label[i] = a;
		label_to_face[a] = i;
	}

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int a, b, c;
		scanf("%d%d", &a, &b);
		a = label_to_face[a];
		b = label_to_face[b];
		c = dice_map[a][b];
		printf("%d\n", face_to_label[c]);
	}

	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
constexpr double pi=3.1415926535897932;
int main(){
    int n;
    cin >> n;
    vector<double> x(n),y(n);
    loop(i,n)cin >> x[i] >> y[i];
    loop(i,n){
        vector<double> theta;
        loop(j,n){
            if(i==j)continue;
            theta.push_back(atan2(y[i]-y[j],x[i]-x[j]));
        }
        sort(theta.begin(),theta.end());
        double probability=0;
        if(theta[n-2]-theta[0]<pi)probability=0.5-(theta[n-2]-theta[0])/(2*pi);
        else{
            loop(i,n-2){
                if(theta[i+1]-theta[i]>pi){
                    probability=-0.5+(theta[i+1]-theta[i])/(2*pi);
                    break;
                }
            }
        }
        cout << setprecision(20) << probability << endl;
    }
    return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())#n学生 mチェックポイント
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(n):
    ans = 0 #答えの初期化
    tmp = 100000000000 #距離初期化
    for j in range(m):
        if tmp > abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1]):
            ans = j
            tmp = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1])
    print(ans+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    sp(10);
    int n;cin>>n;
    vector<pair<double,double>> p(n);
    rep(i,n) cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    double res=0;
    do{
        rep(i,n-1){
            double x=abs(p[i].first-p[i+1].first),y=abs(p[i].second-p[i+1].second);
            x*=x;y*=y;
            double buf=sqrt(x+y);
            res+=buf;
        }
    }while(next_permutation(p.begin(),p.end()));
    double q=1;
    rep1(i,n)q*=i;
    res/=q;
    cout<<res<<endl;
}


Measured memory_bytes: 3844
M = 10**9+7
def pow(x, n):
    if n == 0:
        return 1
    res = pow(x * x % M, n//2)
    if n % 2 == 1:
        res = res * x % M
    return res

if __name__ == "__main__":
    m, n = map(int, input().split())
    ans = pow(m, n)
    print(ans)


Measured memory_bytes: 5600
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define I inline int
#define V inline void
#define isnum(ch) ('0'<=ch&&ch<='9')
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define gc (_op==_ed&&(_ed=(_op=_buf)+fread(_buf,1,100000,stdin),_op==_ed)?EOF:*_op++)
char _buf[100000],*_op(_buf),*_ed(_buf);
I getint(){
	rnt _s=0;re char _ch=gc;
	while(!isnum(_ch))_ch=gc;
	while(isnum(_ch))_s=_s*10+_ch-48,_ch=gc;
	return _s;
}
const int N=1e7+1,mod=998244353;
int n,A,B,ans,fac[N],inv[N];
V input(){n=getint(),A=getint(),B=getint();}
V init(){
	fac[0]=inv[0]=inv[1]=1;
	FOR(i,2,n)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	FOR(i,1,n)inv[i]=1ll*inv[i-1]*inv[i]%mod,fac[i]=1ll*fac[i-1]*i%mod;
}
I C(rnt x,rnt y){return x<0||y<0||x<y?0:1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;}
I f(rnt x,rnt y){return !x&&!y?1:(C(x+y,y)-C(x+y,y-1)+mod)%mod;}
V check(int&x){x-=mod,x+=x>>31&mod;}
V work(){
	rnt lim=min(A,min(n-B,B));
	if(!A&&!B)return void(cout<<1);
	FOR(i,0,lim)check(ans+=1ll*C(n-i-B-1+A-i,A-i)*f(B-1,i)%mod);
	if(n==A+B)check(ans+=f(B-1,A));
	cout<<ans;
}
int main(){
	input();
	init();
	work();
	return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<char>s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    s.at(k - 1) -= ('A' - 'a');
    
    for (int i = 0; i < n; i++) {
        cout << s.at(i);
    }
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf (int)(1e9)
using namespace std;

int n, m;
vector<vector<int>> g, dist;

int solve();

int main() {
  cin >> n >> m;
  g.assign(n, vector<int>(n, 1));
  dist.assign(n, vector<int>(n, inf));
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x][y] = g[y][x] = 0;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i == j)
        dist[i][j] = 0;
      else if (g[i][j])
        dist[i][j] = 1;
  cout << solve() << endl;
  return 0;
}

int solve() {
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k)
        if (dist[i][j] != inf && dist[i][k] != inf &&
            (dist[i][j] & 1) ^ ((dist[i][k] + dist[k][j]) & 1))
          return -1;
  using P = pair<int, int>;
  vector<P> v;
  {
    vector<bool> used(n, 0);
    for (int i = 0; i < n; ++i)
      if (!used[i]) {
        P now(0, 0);
        for (int j = 0; j < n; ++j)
          if (dist[i][j] != inf) {
            used[j] = 1;
            if (dist[i][j] & 1)
              ++now.first;
            else
              ++now.second;
          }
        v.push_back(now);
      }
  }
  int len = v.size(), res = inf;
  vector<vector<int>> dp(len + 1, vector<int>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < len; ++i) {
    for (int j = v[i].first; j <= n; ++j) dp[i + 1][j] |= dp[i][j - v[i].first];
    for (int j = v[i].second; j <= n; ++j)
      dp[i + 1][j] |= dp[i][j - v[i].second];
  }
  for (int i = 0; i <= n; ++i)
    if (dp[len][i])
      res = min(res, (i * (i - 1) / 2) + ((n - i) * (n - i - 1) / 2));
  return res;
}

Measured memory_bytes: 9004
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    string s,t;
    cin >> s >> t;
    bool e = false;
    int k = t.size();
    int n = s.size() - t.size() + 1;
    string ans = "!";
    for(int i = 0; i < n; i++){
        string tmp;
        bool can = true;
        for(int j = 0; j < k; j++){
            if(s[i+j] == '?'){
                continue;
            }else if(s[i+j] == t[j]){
                continue;
            }else{
                can = false;
            }
        }
        int m = i;
        if(can){
            e = true;
            for(int j = 0; j < m; j++){
                if(s[j] == '?'){
                    tmp += 'a';
                }else{
                    tmp += s[j];
                }
            }
            tmp += t;
            for(int j = m + t.size(); j < s.size(); j++){
                if(s[j] == '?'){
                    tmp += 'a';
                }else{
                    tmp += s[j];
                }
            }
            if(ans == "!"){
                ans = tmp;
            }else{
                if(ans > tmp){
                    ans = tmp;
                }
            }
        }
    }
    if(e){
        cout << ans;
    }else{
        cout << "UNRESTORABLE";
    }
}


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

using namespace std;
typedef long long ll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

#define MOD 998244353

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    ll xyz[3*N];

    ll r=0, g=0, b=0;
    for(ll i=0; i<3*N; i++) {
        int o = 0;
        switch(S[i]) {
            case 'R': {
                if(r<g) o++;
                if(r<b) o++;
                r++; break;
            }
            case 'G': {
                if(g<r) o++;
                if(g<b) o++;
                g++; break;
            }
            case 'B': {
                if(b<r) o++;
                if(b<g) o++;
                b++; break;
            }
        }
        xyz[i] = o;
    }

    ll ans=1,cnt1=0,cnt2=0;
    for(ll i=0; i<3*N; i++) {
        switch(xyz[i]){
            case 0:{
                cnt1++;
                break;
            }
            case 1:{
                ans*=cnt1;
                ans%=MOD;
                cnt1--; cnt2++;
                break;
            }
            case 2:{
                ans*=cnt2;
                ans%=MOD;
                cnt2--;
                break;
            }
        }
    }
    for(ll i=0; i<N; i++) {
        ans*=i+1;
        ans%=MOD;
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long

#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >

#define pb push_back

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e4 + 5;
const int mod = 1e9 + 7;

int main()
{
    fast;

    int r, g, b, k;

    cin >> r >> g >> b >> k;

    while(k--){
        if(b > g && g > r){
            cout << "Yes" << endl;
            return 0;
        }

        if(g <= r) g *= 2;
        else if(b <= g) b *= 2;
    }

    if(b > g && g > r) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}




Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}



int main() {
	int c[3][3];
	REP(i, 3)REP(j, 3)cin >> c[i][j];

	int a[3],b[3];
	a[0] = 0;
	REP(i, 3) b[i] = c[0][i];
	a[1] = c[1][0] - b[0], a[2] = c[2][0] - b[0];
	bool ans = true;
	REP(i, 3) {
		REP(j, 3) {
			if (c[i][j] != a[i] + b[j])ans = false;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}



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

const int64_t MOD= 1000000007;
const int Nfac= 2000007;
#define MEMORY 0 // 1/0: 階乗を配列に格納をする前処理をする/しない
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
#if (MEMORY==1)
// 前処理として,階乗を配列に格納をするver.
vector<mint> mfac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  mfac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    mfac.at(i)= mfac.at(i-1)* buf;
  }

  ifac.at(N)= mfac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}
#else
// 前処理を回避するver.
void fact_modp_init(int N= Nfac){}
mint mfac(int N){
  mint ans= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    ans*= buf;
  }

  return ans;
}
#endif

mint binom_modp(int n, int k){
  if(n < 0 || min(k,n-k) < 0) return 0;
  else{
#if (MEMORY==1)
    return mfac.at(n)* ifac.at(k)* ifac.at(n-k);
#else
    k= min(k, n-k);
    mint ans= 1;
    for(int i=1; i<=k; i++){
      mint num= n-i+1;
      ans*= num;
    }
    ans/= mfac(k);

    return ans;
#endif
  }
}

mint multiset_modp(int n, int r){
  if(n==0 && r==0) return 1;
  else{
    return binom_modp(n+r-1, r);
  }
}
// ^^^ テンプレここまで ^^^

int main(){
  int64_t N,K;
  cin >> N >> K;

  mint ans= 0;
  for(int64_t k=K; k<=N+1; k++){
    mint lower= k*(k-1)/2;
    mint upper= k*(2*N- k+ 1)/2;

    ans+= upper- lower+ 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;

namespace lineAralgebra
{
	class Program
	{
		public static int h;
		public static int w;
		public static void Main(String[] args)
		{
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
			h = input[0];
			w = input[1];
			var map = new char[h, w];

			var ans = 0;
			for (var height = 0; height < h; height++)
			{
				var row = Console.ReadLine().ToCharArray();
				for (var width = 0; width < w; width++)
				{
					map[height, width] = row[width];
				}
			}

			for (var height = 0; height < h; height++)
			{

				for (var width = 0; width < w; width++)
				{
					if (map[height, width] == '#') continue;
					ans = Math.Max(BFS(height, width, map), ans);
				}
			}
			System.Console.WriteLine(ans);

		}

		public static int BFS(int height, int width, char[,] map)
		{
			var dx = new int[] { -1, 0, 0, 1 };
			var dy = new int[] { 0, 1, -1, 0 };
			var visited = new bool[h, w];
			var path = new int[h, w];
			var queue = new Queue<Tuple<int, int>>();
			queue.Enqueue(new Tuple<int, int>(height, width));
			var ans = 0;
			visited[height, width] = true;

			while (queue.Count != 0)
			{
				var current = queue.Dequeue();
				for (var i = 0; i < 4; i++)
				{
					var nextY = current.Item1 + dy[i];
					var nextX = current.Item2 + dx[i];
					if (nextY >= h || nextX >= w) continue;
					if (nextY < 0 || nextX < 0) continue;

					var next = new Tuple<int, int>(nextY, nextX);
					if (visited[next.Item1, next.Item2] || map[next.Item1, next.Item2] == '#') continue;
					visited[next.Item1, next.Item2] = true;
					path[next.Item1, next.Item2] = path[current.Item1, current.Item2] + 1;
					ans = Math.Max(ans, path[next.Item1, next.Item2]);
					queue.Enqueue(new Tuple<int, int>(next.Item1, next.Item2));
				}
			}

			return ans;
		}
	}
}



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


  

int main()
{
	long long int i,j,k,l,m,n;
	string s;
	cin>>s;
	n=s.length();
	for(i=0,j=n-1;i<j;i++,j--)
	{
		if(s[i]!=s[j])
		{
			cout<<"No";
			return 0;
		}
	}
	for(i=0,j=((n-1)/2)-1;i<j;i++,j--)
	{
		if(s[i]!=s[j])
		{
			cout<<"No";
			return 0;
		}
	}
	for(i=((n+3)/2)-1,j=n-1;i<j;i++,j--)
	{
		if(s[i]!=s[j])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#define int long long
using namespace std;

int n, a;
int x[50];
int dp[51][51][2551];

signed main() {
	int i, j, k;
	
	cin >> n >> a;
	for (i = 0; i < n; i++) cin >> x[i];
	
	dp[0][0][0] = 1;
	for (i = 0; i < n; i++) {	//今i枚目
		for (j = 0; j < n; j++) {	//j枚選んだ
			for (k = 0; k <= 2500; k++) {	//今までの和がk
				dp[i+1][j][k] += dp[i][j][k];
				dp[i+1][j+1][k+x[i]] += dp[i][j][k];
			}
		}
	}
	
	int ans = 0;
	for (i = 1; i <= n; i++) {
		ans += dp[n][i][a * i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51072
S = list(input())
T = list(input())

st = {s: set() for s in set(S)}
ts = {t: set() for t in set(T)}
for i in range(len(S)):
    st[S[i]].add(T[i])
    ts[T[i]].add(S[i])

for vs, vt in zip(st.values(), ts.values()):
    if len(vs) > 1 or len(vt) > 1:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  string s;
  cin >> n >> m >> s;
  s="#"+s;
  mat v(n+1);
  mat deg(n+1,vec(2));
  vec q,vis(n+1);
  for(ll i=m,x,y;i--;) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    deg[x][s[y]-'A']++;
    deg[y][s[x]-'A']++;
  }
  for(ll i=1;i<=n;i++) {
    if(!deg[i][0]||!deg[i][1]) {
      q.push_back(i);
      vis[i]=1;
    }
  }
  for(ll i=0;i<q.size();i++) {
    for(auto j:v[q[i]]) {
      if(!--deg[j][s[q[i]]-'A']&&!vis[j]) {
        q.push_back(j);
        vis[j]=1;
      }
    }
  }
  cout << (q.size()<n?"Yes":"No") << endl;
}

Measured memory_bytes: 28516
#include <iostream>
using namespace std;
int main()
{
	long long n,ans=0;
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		if (i%3==0 || i%5==0)continue;
		else ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600