akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
/*
struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> size;

    //こいつがいわゆるコンストラクタ
    //初期化している
    UnionFind(int N) : par(N),rank(N),size(N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
            rank[i]=0;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }


    void unite(int x, int y){
        int rx,ry;
        rx = find(x);
        ry = find(y);
        if(rx == ry){
            return;
        }
        else{
            if(rank[rx]<rank[ry]){
                par[rx]=ry;
                size[ry]+=size[rx];
            }
            else{
                par[ry]=rx;
                size[rx]+=size[ry];
                if(rank[rx]==rank[ry]){
                    rank[rx]++;
                }
            }
        }
    }


    bool same(int x,int y){
        return find(x) == find(y);
    }
};
*/

int main(){
    int x;
    cin>>x;
    if(x==1){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3592
def main():
    import copy
    n, k  = map(int, input().split())
    takasa_lis = list(map(int, input().split()))
   
    ans = 10**200
    
    for i in range(0, 2 ** n, 2):
        test_lis = copy.deepcopy(takasa_lis)
        cnt = 0
        building_cost = 0
        for j in range(1, n):
            if ((i>>j) & 1):
                cnt += 1
                building_cost += max(max(test_lis[0:j]) - test_lis[j] + 1, 0)
                test_lis[j] = max(max(test_lis[0:j])+1, test_lis[j])
            else:
                if test_lis[j] > max(test_lis[0:j]):
                    cnt += 1
        if cnt >= k-1 and ans > building_cost:
            ans = building_cost
    
    print(ans)


    


if __name__ == "__main__":
    main()


Measured memory_bytes: 47448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int n=1;
    int X=0;
    cin >> N;

    int i;
    for(i=1;i<=8;i++){
        if ((N/n)!=0){
        X += (N/n)%10;
        n=n*10;
        }else{
        break;
        }
    }
  
    if(N%X==0){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}

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

signed main(void)
{
	int n, k;
	long long ans;
	string s, t;

	cin >> n >> k >> s;
	ans = 0;
	rep(i, n - 1)
	{
		if (s[i] == s[i + 1])
			ans++;
	}
	ans = min((int)ans + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
// Example program
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int a;
    int b;
    int c;
    cin >> a;
    cin >> b;
    cin >> c;
    vector<int> v{a,b,c};
    sort(v.begin(),v.end());
    cout << v[0] << " " << v[1] << " " << v[2] << endl;
}

Measured memory_bytes: 3084
n, time = [int(_) for _ in input().split()]
t = [int(_) for _ in input().split()]

off_total = 0
for i in range(0, n-1):
    if t[i+1] - t[i] > time:
        off_total += t[i+1] - t[i] - time

print(t[-1] + time - off_total)

Measured memory_bytes: 25200
n = int(input())
sa = [0]*n
for i in range(n):
    sa[i]= str(input())
a = 0
w =0
t=0
r=0

for s in sa:
    if s == "AC":
        a+=1
    if s == "WA":
        w+=1
    if s == "TLE":
        t+=1
    if s == "RE":
        r+=1

print("AC x "+str(a))
print("WA x "+str(w))
print("TLE x "+str(t))
print("RE x "+str(r))


Measured memory_bytes: 78440
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
	int A,B,H,M;
	double thA,thB,cosa,sina,cosb,sinb,ans;
	cin>>A>>B>>H>>M;
	thA=(double)(H+M/60.0)/6*acos(-1);
	thB=(double)M/30*acos(-1);
	cosa=A*cos(thA);
	sina=A*sin(thA);
	cosb=B*cos(thB);
	sinb=B*sin(thB);
	ans=(cosa-cosb)*(cosa-cosb)+(sina-sinb)*(sina-sinb);
	ans=sqrt(ans);
	cout<<std::setprecision(15)<<ans;
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3632
#include <stdio.h>

void push(int num, int *idx, int stack[]) {
  stack[*idx] = num;
  ++*idx;
}

int pop(int *idx, int stack[]) {
  --*idx;
  return stack[*idx];
}

int main(void) {
  int train, idx = 0, stack[10];

  while (scanf("%d", &train) != EOF) {
    if (train == 0) {
      printf("%d\n", pop(&idx, stack));
    } else {
      push(train, &idx, stack);
    }
  }

  return 0;
}

Measured memory_bytes: 600
h, w = map(int, input().split())
mas = []

for _ in range(h):
    row = input()
    if '#' in row:
        mas.append(list(row))

ignore_col = []
for i in range(w):
    cnt = 0
    for j in range(len(mas)):
        if mas[j][i] == '#':
            break
        cnt += 1
    if cnt == len(mas):
        ignore_col.append(i)

for i in range(len(mas)):
    tmp = []
    for j in range(w):
        if j in ignore_col:
            continue
        tmp.append(mas[i][j])
    print(''.join(tmp))


Measured memory_bytes: 3188
object Main {

  def main(args: Array[String]) {
    val source = scala.io.Source.stdin.getLines

    while(true) {
      val  input: Array[Int] = source.next().split(" ").map(_.toInt)

      if (input.forall(_ == 0)) {
        return
      }

      val datas: Array[Int] = source.take(input(0)).map(_.toInt).toArray
      val maximum: (Int, Int) =  (input(1) to input(2)).map(n => (n, datas(n - 1) - datas(n))).reverse.maxBy(v => v._2)

      println(maximum._1)

    }
  }
}

Measured memory_bytes: 53728
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> s(n, 0);
    ll tot = 0;
    REP(i, n) {
        cin >> s[i];
        tot += s[i];
    }

    if (tot%10 != 0){
        cout << tot << endl;
        return 0;
    }

    sort(ALL(s));

    REP(i, n){
        if (s[i] % 10 != 0){
            cout <<  tot - s[i] << endl;
            return 0;
        }
    }
    cout << "0" << endl;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int N;
int a[3];

bool ch()
{
	int b = 2;
	rep(i, N) {
		if (b == 2) {
			if (a[0]) {
				a[0]--;
				b = 0;
			} else if (a[1]) {
				a[1]--;
				b = 1;
			} else {
				return true;
			}
		} else if (b == 1) {
			if (a[1]) {
				a[1]--;
				b = 1;
			} else if (a[2] == 0) {
				return false;
			} else {
				a[2]--;
				b = 2;
			}
		} else {
			if (a[2]) {
				a[2]--;
				b = 2;
			} else {
				return false;
			}
		}
	}
	return true;
}


int main()
{
	cin >> N;
	rep(i, N) {
		CIN(int, t);
		if (t % 4 == 0) a[2]++;
		else if(t % 2 == 0) a[1]++;
		else a[0]++;
	}
	PRINT(ch());
}


Measured memory_bytes: 256
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 998244353;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 3000 + 5;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
string s, t, ans = "", tmp = "";
int mem[N][N];
int cnt(int i, int j) {
	if (i == s.size() || j == t.size())
		return 0;
	int& ret = mem[i][j];
	if (~ret)return ret;
	if (s[i] == t[j])
	{
		return ret = 1 + cnt(i + 1, j + 1);
	}
	return ret = max(cnt(i + 1, j), cnt(i, j + 1));
}
void solve(int i, int j) {
	if (i == s.size() || j == t.size())
		return ;
	if (s[i] == t[j])
	{
		ans += s[i];
		return solve(i + 1, j + 1);
	}
	if (mem[i + 1][j] > mem[i][j + 1]) {
		return solve(i + 1, j);

	}
	return solve(i, j + 1);
}
int main()
{
	Ma7moud_7amdy;
	//Open_Sesame;
	clr(mem, -1);
	cin >> s >> t;
	cnt(0, 0);
	solve(0, 0);
	cout << ans;
	return Accepted;
}


Measured memory_bytes: 35840
namespace ABC143.C
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;


    public class Program
    {

        public static void Main(string[] args)
        {
            var n = ReadInputAsInt();
            var s = ReadLine();
            WriteLine(Solve(s));

        }

        public static long Solve(string s)
        {
            int count = 1;
            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] != s[i + 1]) count++;
            }
            return count;
        }

        static int ReadInputAsInt() => int.Parse(ReadLine());

    }
}


Measured memory_bytes: 13116
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int N, Q;
    cin >> N >> Q;

    ll K = 0;
    while (Q--) {
        ll q, k;
        cin >> q >> k;
        if (q == 0) {
            ll ans = (K + k) % N;
            if(ans == 0) ans = N;
            cout << ans << endl;
        } else {
            K = (K + k) % N;
        }
    }


    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<ll> c(N);
	for (int i = 0; i < N; ++i) { cin >> c[i]; }
	sort(c.rbegin(), c.rend());

	ll sum = 0;
	for (int i = 1; i < N; ++i) { sum += c[i]; }
	vector<ll> res(N, -1);
	res[0] = c[0];
	int idx = 1;
	deque<int> que;
	que.push_back(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop_front();
		for (int i = 0; i < g[v].size(); ++i) {
			int u = g[v][i];
			if (res[u] > 0) { continue; }
			res[u] = c[idx];
			++idx;
			que.push_back(u);
		}
	}

	cout << sum << endl;
	for (int i = 0; i < N; ++i) {
		cout << res[i] << (i == N - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 1152
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

x=[]
y=[]

for i in range(n):
    if i==0:
        x.append(a[i])
        y.append(b[i])
    else:
        x.append(x[-1]+a[i])
        y.append(y[-1]+b[i])

ans=0

for i in range(n):
    if i==0:
        ans=max(ans,x[i]+y[-1])
    else:
        ans=max(ans,x[i]+y[-1]-y[i-1])

print(ans)

    

Measured memory_bytes: 3064
function Main(input) {
  input.trim();
  input = input.split("\n");
  var N = input[0];
  var arr = input[1].split(" ").map(Number);
  var ans = 0;
  var low = 9999999999999999;
  for(var i=0;i<N;i++){
    if(low>=arr[i]){ans++;low = arr[i];}
  }
  console.log(ans);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}

Measured memory_bytes: 26320
#include<stdio.h>

int main()
{
  int n;
  int a[100][2];
  int i;
  
  scanf("%d",&n);
  
  for(i=0;i<=n;i++)
  {
    scanf("%d %d",&a[i][1],&a[i][2]);
  }
  
  for(i=0;i<n-2;i++)
  {
    if(a[i][1]==a[i][2] && a[i+1][1]==a[i+1][2] &&  a[i+2][1]==a[i+2][2])
    {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 1692
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#define pp pair<int, int>
#define mp make_pair
using namespace std;
const int maxn = 2010;
int n, m, con[maxn][maxn], up[maxn][maxn], down[maxn][maxn];
char squ[maxn][maxn];
bool grid[maxn][maxn];
stack<pp>s; 
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m;
	if(n == 1)
	{
		cout << m << endl;
		return 0;
	}
	if(m == 1)
	{
		cout << n << endl;
		return 0;
	}
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++)
			cin >> squ[i][j];
	for(int i = 1; i < n; i ++)
		for(int j = 1; j < m; j ++)
		{
			int cnt = (squ[i][j] == '.') + (squ[i + 1][j] == '.') + (squ[i][j + 1] == '.') + (squ[i + 1][j + 1] == '.');
			if(cnt % 2 == 0)
				grid[i][j] = 1;
			else
				grid[i][j] = 0;
		}
	for(int i = 1; i < n; i ++)
	{
		int last = 0;
		for(int j = 1; j < m; j ++)
		{
			if(grid[i][j] == 0)
				con[i][j] = last = 0;
			else
			{
				if(last == 0)
				{
					int k = j;
					for(; k < m && grid[i][k] == 1; k ++);
					con[i][j] = last = k - j;
				}
				else
					con[i][j] = --last;
			}
		}
	}
	for(int j = 1; j < m; j ++)
	{
		for(int i = 1; i < n; i ++)
		{
			pp a = mp(con[i][j], i);
			while(!s.empty() && s.top().first > con[i][j])
			{
				down[s.top().second][j] = i - s.top().second;
				s.pop();
			}
			s.push(a);
		}
		while(!s.empty())
		{
			down[s.top().second][j] = n - s.top().second;
			s.pop();
		}
	}
	for(int j = 1; j < m; j ++)
	{
		for(int i = n - 1; i; i --)
		{
			pp a = mp(con[i][j], i);
			while(!s.empty() && s.top().first > con[i][j])
			{
				up[s.top().second][j] = s.top().second - i;
				s.pop();
			}
			s.push(a);
		}
		while(!s.empty())
		{
			up[s.top().second][j] = s.top().second;
			s.pop();
		}
	}
	int mx = 0;
	for(int i = 1; i < n; i ++)
		for(int j = 1; j < m; j ++)
			mx = max((up[i][j] + down[i][j]) * (con[i][j] + 1), mx);
	cout << max(mx, max(n, m)) << endl;
	return 0;
}

Measured memory_bytes: 55424
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		pair<int, char> scores[10];
		for (int i = 0; i < n; ++i)
		{
			char name;
			scanf(" %c", &name);
			int w, l;
			w = l = 0;
			for (int j = 1; j < n; ++j)
			{
				int t;
				scanf("%d", &t);
				if (t == 0)
					++w;
				else if (t == 1)
					++l;
			}
			scores[i] = make_pair(w*10000 - l*100 + 10-i, name);
		}
		sort(scores, scores+n, greater<pair<int, char> >());
		for (int i = 0; i < n; ++i)
			printf("%c\n", scores[i].second);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n,n2,dansa,m,M,tmp;
  cin >> n;
  while( n-- )
    {
      cin >> n2;
      M = m = 0;
      cin >> dansa;
      tmp = dansa;
      for(int i = 1 ; i < n2 ; i++)
	{
	  cin >> dansa;
	  M = max(dansa-tmp,M);
	  m = max(tmp-dansa,m);
	  tmp = dansa;
	}
      cout << M << " " << m << endl;
    }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<int> mp[105000];
int N, M;
int P[105000], Y[105000];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> P[i] >> Y[i];
        mp[P[i]].push_back(Y[i]);
    }
    for(int i = 1; i <= N; i++) {
        sort(mp[i].begin(), mp[i].end());
    }
    for(int i = 1; i <= M; i++) {
        string p = to_string(P[i]);
        auto itr = lower_bound(mp[P[i]].begin(), mp[P[i]].end(), Y[i]);
        int j = distance(mp[P[i]].begin(), itr) + 1;
        string x = to_string(j);
        while(p.size() < 6) p = "0" + p;
        while(x.size() < 6) x = "0" + x;
        cout << p << x << endl;
    }
    return 0;
}


Measured memory_bytes: 7936
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	count := 0
	for i, v := range s {
		if i == 0 {
			if v != 'A' {
				fmt.Println("WA")
				return
			}
		} else if 2 <= i && i <= len(s)-2 {
			if v == 'C' {
				count++
			} else if v < 'a' || 'z' < v {
				fmt.Println("WA")
				return
			}
		} else if v < 'a' || 'z' < v {
			fmt.Println("WA")
			return
		}
	}
	if count == 1 {
		fmt.Println("AC")
		return
	}
	fmt.Println("WA")
}


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

int main(){
  int s=0, s1=0, s2=0, s3=0;
  cin >> s;
  s1 = s / 100;
  s3 = s % 10;
  s2 = (s - s3) / 10 % 10;
  cout << s1 + s2 + s3 << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>
#include <bitset>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int K;
char S[5010];
vector<string> v;

signed main()
{
	cin >> S;
	cin >> K;
	int len = strlen(S);

	REP(i, 5)
	{
		REP(j, len - i)
		{
			string s;
			REP(k, i + 1)
			{
				s += S[j + k];
			}
			if (!CONTAINS(v, s))
			{
				v.push_back(s);
			}
		}
	}

	SORT(v);

	cout << v[K - 1] << endl;
}


Measured memory_bytes: 1024
def coins():
    import itertools

    A = [i for i in range(int(input())+1)]
    B = [i for i in range(int(input())+1)]
    C = [i for i in range(int(input())+1)]
    X = int(input())

    p = list(itertools.product(A,B,C))
    count = 0
    for i in p:
        sum = 500*i[0] + 100*i[1] + 50*i[2]
        if sum == X:
            count+=1

    print(count)

if __name__ == "__main__":
    coins()


Measured memory_bytes: 13604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define LE(n,m) ((n)<(m)+EPS)
const double EPS=1e-8;
const int MAX_N=51,MAX_Q=51;

int N,Q;

double x[MAX_N],y[MAX_N],z[MAX_N],r[MAX_N];
ll l[MAX_N];
double sx[MAX_Q],sy[MAX_Q],sz[MAX_Q];
double dx[MAX_Q],dy[MAX_Q],dz[MAX_Q];

vector<double> proj(int n,int q,bool &point_on_linesegment){
    double X=dx[q]-sx[q],Y=dy[q]-sy[q],Z=dz[q]-sz[q];
    double t=((x[n]-sx[q])*X+(y[n]-sy[q])*Y+(z[n]-sz[q])*Z)/(X*X+Y*Y+Z*Z);
    if (LE(t,0)||LE(1,t)) point_on_linesegment=false;
    return {sx[q]+t*X,sy[q]+t*Y,sz[q]+t*Z};
}

double distPP(double x1,double y1,double z1,double x2,double y2,double z2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);
}

double distSP(int n,int q){
    bool check=true;
    vector<double> v=proj(n,q,check);
    if (check) return distPP(v[0],v[1],v[2],x[n],y[n],z[n]);
    else return min(distPP(sx[q],sy[q],sz[q],x[n],y[n],z[n])
                    ,distPP(dx[q],dy[q],dz[q],x[n],y[n],z[n]));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    for (int i=0;i<N;++i) cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
    for (int i=0;i<Q;++i) cin >> sx[i] >> sy[i] >> sz[i] >> dx[i] >> dy[i] >> dz[i];
    for (int j=0;j<Q;++j){
        ll ans=0;
        for (int i=0;i<N;++i)
            if (LE(distSP(i,j),r[i]*r[i]))
                ans+=l[i];
        cout << ans << '\n';
    }
}


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

int main(){
	int n,y,k;
	cin>>n>>y;
	for(int i=0; i<=y/10000; i++){
		for(int j=0; j<=y/5000; j++){
			k=n-i-j;
			if(k>=0 && i*10000+j*5000+k*1000==y){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
s = input()

n = 1
cur_st = s[0]

indx = 1
while indx < len(s):
  if s[indx] != cur_st:
    cur_st = s[indx]
    indx += 1
    n += 1
  else:
    if indx + 1 < len(s):
      cur_st = s[indx] + s[indx + 1]
      n += 1
      indx += 2
    else:
      indx += 1
  # print(cur_st, n)

print(n)

Measured memory_bytes: 3500
#define _USE_MATH_DEFINES
#include<cmath>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main(){
	int a, b, ans;
	string op;

	while (1){

		cin >> a >> op >> b;


		if (op == "+")
			ans = a + b;
		else if (op == "-")
			ans = a - b;
		else if (op == "*")
			ans = a * b;
		else if (op == "/")
			ans = a / b;
		else
			break;

		//cout << fixed << setprecision(5);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
# ダブリングを使って解く
n, k = map(int, input().split())
a = list(map(int, input().split()))

cur = 0
pre_doubling = list(range(1, n+1))
doubling = a[:]
while k > 0:
    if k & 1:
        cur = doubling[cur] - 1
    k >>= 1
    pre_doubling = doubling[:]
    for i in range(n):
        doubling[i] = pre_doubling[pre_doubling[i]-1]
print(cur+1)

Measured memory_bytes: 168964
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

double getFrac(int n) {
    int result = 1;
    while (n > 0) {
        result *= n;
        n--;
    }
    return result;
}

int main(void) {
    int N;
    cin>>N;
    vector<int> X,Y,index;
    for (int i = 0; i < N; i++)
    {
        int x,y;
        cin>>x>>y;
        index.push_back(i);
        X.push_back(x);
        Y.push_back(y);
    }
    double distance_sum = 0;
    do {
        double dis = 0;
        for (int i = 1; i < N; i++)
        {
            dis += sqrt(pow(X.at(index.at(i - 1)) - X.at(index.at(i)), 2) + pow(Y.at(index.at(i - 1)) - Y.at(index.at(i)), 2));
        }
        distance_sum += dis;
    } while (next_permutation(index.begin(), index.end()));
    printf("%.6f\n", distance_sum / getFrac(N));
    return 0;
}

Measured memory_bytes: 256
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using VC = vector<char>;
using VVC = vector<VC>;

int main(){
	int n,m,p,sz,ac=0,wa=0;
	string s;

	cin>>n>>m;
	VVC P(n);
	rp(i, 0, m){
		cin>>p>>s; --p;
		sz = P[p].size();
		if(sz && P[p][sz-1]=='A') continue;
		P[p].push_back(s[0]);
	}

	for(auto v:P){
		sz = v.size();
		if(sz==0) continue;
		if(v[sz-1]=='W') continue;
		ac++;
		wa += sz-1;
	}

	cout<< ac <<" "<< wa <<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;

    int current_max;
    cin >> current_max;

    rep1(i, n){
        int h;
        cin >> h;

        if(current_max-1 > h){
            puts("No");
            return 0;
        }

        current_max = max(current_max, h);
    }

    puts("Yes");

    return 0;
}

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

g = [[0] * n for _ in range(n)]

for i in range(n):
    for j in range(i + 1, n):
        xor = i ^ j
        val = 1
        while xor:
            if xor & 1:
                g[i][j] = val
            xor >>= 1
            val += 1

for i, row in enumerate(g, 1):
    print(*row[i:])


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long sum = 0;
		for(int i=0;i<N;i++) sum += A[i];
		
		long inc = (long)N * (long) (N+1) / 2;
		if(sum % inc != 0){
			Console.WriteLine("NO");
			return;
		}
		
		long tot = sum / inc;
		
		long[] B = new long[N];
		for(int i=0;i<N;i++){
			long diff = A[i] - A[(i-1+N)%N];
			if((tot - diff) % N != 0){
				Console.WriteLine("NO");
				return;
			}
			B[i] = (tot - diff)/N;
			if(B[i] < 0){
				Console.WriteLine("NO");
				return;
			}
		}
		
		long cnt = 0;
		for(int i=0;i<N;i++) cnt += B[i];
		if(cnt != tot){
			Console.WriteLine("NO");
			return;
		}
		
		//Console.WriteLine(String.Join(" ",B));
		
		long a = 0;
		for(int i=0;i<N;i++){
			a += B[i] * (N-i);
		}
		
		//Console.WriteLine(a);
		
		
		Console.WriteLine(a == A[N-1] ? "YES": "NO");
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13400
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
	int a, b;
	cin >> a;
	cin >> b;
	cout << max(a - b, max(a + b, a * b));

 

}



Measured memory_bytes: 256
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 10000001;
int a[N];

int32_t main(){
	for (int i = 1; i < N; i++){
		for (int j = i; j < N; j += i){
			a[j] ++;
		}
	}
//	for (int i = 1; i <= 10; i++)
//		cout << a[i] << endl;
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++){
		ans += i * a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 81772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int n;
ll a[405];
ll dp[405][405];
ll s[405];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	memset(dp,0x7f,sizeof(dp));
	for (int i=1;i<=n;++i){
		cin>>a[i];s[i]=s[i-1]+a[i];
	}
	for (int i=1;i<=n;++i) dp[i][i]=0;
	for (int l=1;l<n;++l){
		for (int x=1;x+l<=n;++x){
			for (int m=x;m<x+l;++m){
				dp[x][x+l]=min(dp[x][x+l],dp[x][m]+dp[m+1][x+l]);
			}
			dp[x][x+l]+=s[x+l]-s[x-1];
		}
	}
	cout<<dp[1][n]<<endl;
	return 0; 
}

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

vector<int> x, y, z;

void push(int a, int b, int c) {
  x.push_back(a); y.push_back(b); z.push_back(c);
}

void pop() {
  x.pop_back(); y.pop_back(); z.pop_back();
}

void print() {
  for (int i = 0; i < (int) x.size(); i++) {
    cout << x[i] << " " << y[i] << " " << z[i] << endl;
  }
}

int main(){
  int l; cin >> l; l--;
  bitset<20> bit = l;
  int n = 1; int m = l+1; bool flg = true;
  while (m != 1) {
    if (m % 2 == 1) flg = false;
    m /= 2; n++;
  }
  if (!flg) {
    n+=1;
    for (int i = 0; i < n-2; i++) {
      push(n-i-2, n-i-1, 0);
      push(n-i-2, n-i-1, pow(2, i));
    }
    int cnt = pow(2, n-2);
    for (int i = 3; i <= n; i++) {
      if (cnt + pow(2, n-i)-1 <= l) {
        push(1, i-1, cnt);
        cnt += pow(2, n-i);
      }
    }
    cout << n-1 << " " << x.size() << endl;
    print();
  } else {
    for (int i = 0; i < n-1; i++) {
      push(n-i-1, n-i, 0);
      push(n-i-1, n-i, pow(2, i));
    }
    cout << n << " " << x.size() << endl;
    print();
  }
  return 0;
}


Measured memory_bytes: 256
n,i;main(m){for(;scanf("%d%d",&n,&m)*m;){int c[100]={i=0},d=m,v;for(;i<n*m;c[i++%m]+=v)scanf("%d",&v);for(;n;n--)for(i=0;i<m;)c[i++]-n||printf("%d%c",i,--d?32:10);}}

Measured memory_bytes: 416
#include <stdio.h>

int main(void){
	int A[10], b, c, n, i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		for (j = 0; j < 10; j++){
			scanf("%d", &A[j]);
		}
		b = A[0];
		c = 0;
		for (j = 1; j < 10; j++){
			if (b < A[j]){
				b = A[j];
			}else if (c < A[j]){
				c = A[j];
			}else {
				printf("NO\n"); break;
			}
			if (j == 9) printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    ll ans = 0;
    for(int i=1; i<=n; i++){
        if(i%3 == 0 || i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
import collections

n=int(input())
a=list(map(int,input().split()))
num=collections.Counter(a)
cnt=num.most_common()
if cnt[0][1]<=1:
    print(0)
    exit()
else:
    if cnt[1][1]<=1:
        print(0)
        exit()
    numlis=[]
    for i in cnt:
        if i[1]>=2:
            numlis.append(i)
        else:
            break
    numlis=[list(a) for a in numlis]
    numlis.sort(reverse=True)
    if numlis[0][1]>=4:
        print(numlis[0][0]**2)
    else:
        print(numlis[0][0]*numlis[1][0])



Measured memory_bytes: 71832
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    long long int n, m;
    
    cin >> n >> m;
    
    
    if((n == 1) && (m == 1)) {
        cout << "1\n";
    } else if((n == 1) || (m == 1)) {
        cout << max(n, m) - 2 << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }
    
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int train, bus;
    train = min(a, b);
    bus = min(c, d);
    cout << train + bus << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 1001000
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    LL max_num=0;
    for(LL i=0; i<n; i++){
        cin >> a[i];
        max_num=max(max_num, a[i]);
    }

    vector<LL> num_sum(max_num+1, 0);

    for(LL i=0; i<n; i++){
        for(LL j=2; j*j<=a[i]; j++){
            if(a[i]%j==0){
                while(a[i]%j==0){
                    a[i]/=j;
                }
                num_sum[j]++;
            }
        }
        if(a[i]!=1){
            num_sum[a[i]]++;
        }
    }

    LL max_ans=0;
    for(LL i=0; i<num_sum.size(); i++){
        max_ans=max(max_ans, num_sum[i]);
    }

    if(max_ans==1 || max_ans==0){
        cout << "pairwise coprime" << endl;
    }else if(max_ans<n){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }

    return 0;
}


Measured memory_bytes: 18696
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N; string S[1 << 18];
int c1, c2, c3, c4;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i];
		if (S[i] == "AC") c1++;
		if (S[i] == "WA") c2++;
		if (S[i] == "TLE") c3++;
		if (S[i] == "RE") c4++;
	}
	cout << "AC x " << c1 << endl;
	cout << "WA x " << c2 << endl;
	cout << "TLE x " << c3 << endl;
	cout << "RE x " << c4 << endl;
	return 0;
}

Measured memory_bytes: 11824
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    LL n, m;
    cin >> n >> m;
    if(n == 1 || m == 1) {
        if(n == 1 && m == 1) cout << 1 << endl;
        else cout << max(n, m) - 2 << endl;
    }
    else cout << (n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
import sys


def main():
    n, m = map(int, sys.stdin.readline().split())
    g = [[] for i in range(n)]
    for i in range(m):
        l, r, d = map(int, sys.stdin.readline().split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 77472
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

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

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

  vector<char> S(N);

  rep(i,N) cin>>S[i];

  rep(i,N) if(S[i]=='Y'){
  cout<<"Four"<<endl;
  goto xyz;
  }
  cout<<"Three"<<endl;
xyz:;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 H, W;
    cin >> H >> W;
    char s[60][60] = {0};
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> s[i][j];
        }
    }
    
    int cnt = 0;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(s[i][j] == '#'){
                if(s[i+1][j] == '.' &&  s[i][j+1] == '.'  && s[i-1][j] == '.' && s[i][j-1] == '.'){
                    cnt++;
                }
            }
        }
    }

    if(cnt == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define em emplace_back
#define sqr(x) (x) * (x)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1E9;
const ld TM = 0.006;

int main() {
    ios_base::sync_with_stdio(0);
    int n, t, a, ans = 1, x;
    ld vl = INF;
    cin >> n >> t >> a;

    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (abs(ld(t) - TM * ld(x) - ld(a)) < vl) {
            ans = i + 1;
            vl = abs(ld(t) - TM * ld(x) - ld(a));
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        ll k[n];
        for(int i = 0; i < n; i++)  cin >> k[i], k[i] %= m;
        for(int i = 1; i < n; i++)  k[i] = (k[i]+k[i-1])%m;
        set<ll> s;
        s.insert(0);
        ll ans = 0;
        for(int i = 0; i < n; i++){
            auto r = s.upper_bound(k[i]);
            if(r == s.end())    r = s.begin();
            ans = max(ans, (k[i]-(*r)+m)%m);
            s.insert(k[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4544
#include<iostream>

using namespace std;

int main()
{
    int num;
    cin>>num;

    switch(num%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            printf("hon\n");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            printf("pon\n");
            break;
        case 3:
            printf("bon\n");
            break;
    }

    return 0;
}


Measured memory_bytes: 3592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long; using ld = long double;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

void solve() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        uf.unite(x,y);
    }
    
    int ans = 0;
    rep(i,n) ans = max(ans, uf.size(i));
    cout << ans << endl;
}

int main(){

    solve();
    
}

Measured memory_bytes: 4040
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    #output
    p = sorted(p)
    answer = sum(p[:K])
    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9248
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
std::vector<edge>V[100010], W[100010];
typedef std::vector<std::vector<int>>ma;
std::vector<int>v[200010];
bool d[200010];

void dfs(int a) {
	d[a] = true;
	for (int i = 0;i < v[a].size();i++) {
		if (!d[v[a][i]]) {
			d[v[a][i]] = true;
			dfs(v[a][i]);
		}
	}
}

int main() {
	ll n, m;
	std::cin >> n >> m;
	for (int i = 1;i <= n;i++) {
		int k;
		std::cin >> k;
		for (int j = 0;j < k;j++) {
			int l;
			std::cin >> l;
			v[i + 100000].push_back(l);
			v[l].push_back(i + 100000);
		}
	}
	dfs(100001);
	for (int i = 100001;i <= 100000 + n;i++) {
		if (!d[i])flag = false;
	}
	if (flag)std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}

Measured memory_bytes: 13312