akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int H,W;
    char a[110][110]={};
    cin>>H>>W;

    for(int i=0;i<=H+1;i++){
        for(int j=0;j<=W+1;j++){
            if(i==0||i==H+1||j==0||j==W+1){
                cout<<"#";
            }else{
                cin>>a[i][j];
                cout<<a[i][j];
            }

            if(j==(W+1)){
                cout<<endl;
            }
        }
    }

    return 0;
}

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

int main() {
  string s;
  int cnt = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == '1'){
      cnt++;
    }
  }
  
  cout << cnt;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	//cout<<"";
        }
      	//cout<<"";
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
  	//cout<<"";
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	//cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


Measured memory_bytes: 1792
#include <math.h>
#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr long long INFLL = 1e18;

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int time = n / x;
  int a = n % x;
  if (a == 0) {
    cout << time * t << endl;
  } else {
    cout << (time + 1) * t << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#!/usr/bin/python3
# abc061_b

"""
Counting Roads
"""

def answer():
    """
    答えをN行で出力する。
    """
    N, M = map(int, input().split())
    load = []
    for _ in range(M):
        load += list(map(int, input().split()))

    # 各都市の出現回数を2で割ったものを出力する。
    for i in range(1, N+1):
        print(load.count(i))


def main():
    """
    処理を実行する。
    """
    answer()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a, b;
		a = sc.next();
		b = sc.next();
		int x = Integer.parseInt(a + b);

		for (int i = 1; i <= 1000; i++) {
			if(i * i == x) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    long long x;

    scanf("%lld", &x);

    if(x % 11 == 0){
        printf("%lld\n", 2 * (x / 11));
    }else if(x % 11 > 6){
        printf("%lld\n", 2 * (x / 11) + 2);
    }else{
        printf("%lld\n", 2 * (x / 11) + 1);
    }

    return 0;
}

Measured memory_bytes: 1732
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 and c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())


Measured memory_bytes: 3060
#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 n;
    cin >> n;
    vector<string> s(n);
    map<string, int> ans;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        ans[s[i]]++;
    }
    printf("AC x %d\n", ans["AC"]);
    printf("WA x %d\n", ans["WA"]);
    printf("TLE x %d\n", ans["TLE"]);
    printf("RE x %d\n", ans["RE"]);

    return 0;
}

Measured memory_bytes: 6404
/* AOJ 0077
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0077
 *
 */

#include <stdio.h>
#include <string.h>

#define BUFSIZE 101



void decode(char* buf){
    int n, i;

    while(*buf){
        if(*buf=='@'){
            buf++;
            n = *buf - '0';
            buf++;
            for(i=0;i<n;i++){
                printf("%c", *buf);
            }
        }else{
            printf("%c", *buf);
        }
        buf++;
    }

}


int main(){
    char buf[BUFSIZE];

    while(scanf("%s", buf)==1){
        decode(buf);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int N;
string S;

bool check_do(int len){
  map<string,PII> mp;
  rep(i,S.length()-len+1){
    int x = mp.count(S.substr(i,len));
    if(x == 1 && i >= mp[S.substr(i,len)].second+len) return true;
    else if( x == 0) mp[S.substr(i,len)] = PII(1,i);
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N;
  cin >> S;
  int s = 0, e = S.length()+1;
  while(e-s>1){
    int m = (s+e)/2;
    if(check_do(m)) s = m;
    else e = m;
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 6696
#include<stdio.h>
int main(void){
  int n,a=0,b=0,c=0,d=0,i=0;
  while(scanf("%d",&n)!=EOF){
    i=0; 
   for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<9;d++){
	    if(c<10 && b<10){
	    if(a+b+c+d==n){
	      i++;
	    }
	    }
	  }
	  if(c<10 && b<10){
	  if(a+b+c+d==n){
	    i++;
	  }
	  }
	}
	if(c<10 && b<10){
	if(a+b+c+d==n){
	  i++;
	}
	}
      }
      if(c<10 && b<10){
      if(a+b+c+d==n){
	i++;
      }
      }
   }
    printf("%d\n",i);
  }
return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    map<string, int> table;
    rep(i,n){
        string s;
        cin >> s;
        table[s]++;
    }
    int maxValue = 0;
    for(const auto& p : table) maxValue = max(maxValue, p.second);
    for(const auto& p : table){
        if(maxValue != p.second) continue;
        cout << p.first << endl; 
    }
}

Measured memory_bytes: 19096
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
	
		if((A == B && B == C) || (A != B) && (B != C) && (A!= C)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	

	}

}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

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

void solve()
{
	int A, B, K;
	cin >> A >> B >> K;
	int large = max(A, B);
	int cnt = 0;
	vector<int> div;
	for (int i = 1; i <= large; ++i)
	{
		if (A % i == 0 && B % i == 0)
		{
			div.push_back(i);
		}
	}
	cout << div[div.size() - K] << endl;
}

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

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        Collections.reverse(list);
        int a = 0;
        int b = 0;
        for (int i = 0; i < n; i++) {
            if(i % 2 == 0) a += list.get(i);
            else b += list.get(i);
        }
        System.out.println(a - b);
    }
}

Measured memory_bytes: 35892
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    vector<int>a;
    cin>>n>>k;
    a.resize(n);
    rep(i,n)cin>>a[i];
    sort(ALL(a));
    int sum=0;
    rep(i,k)sum+=a[i];
    cout<<sum<<"\n";
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    vecll a(n), b(n), c(n - 1);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;
    for(auto& i : c) cin >> i;

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += b.at(a.at(i) - 1);
        if(i > 0) if(a.at(i) == a.at(i - 1) + 1) ans += c.at(a.at(i - 1) - 1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans

Measured memory_bytes: 6388
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = LI()
    G[a - 1] += [(b - 1, c)]


def bellman_ford(G, start=0):
    n = len(G)
    costs = [-INF] * n
    costs[0] = 0
    v_nows = set([start])
    for _ in range(n):
        v_changeds = set()
        for u in v_nows:
            for v, c in G[u]:
                if costs[u] + c > costs[v]:
                    costs[v] = costs[u] + c
                    v_changeds.add(v)
        v_nows = v_changeds
    if not v_changeds:
        return costs[n - 1]

    for i in v_nows:
        costs[i] = INF
    que = deque(v_nows)
    while que:
        u = que.popleft()
        for v, _ in G[u]:
            if costs[v] != INF:
                costs[v] = INF
                que += [v]
    return costs[n - 1]


cost = bellman_ford(G, 0)
if cost == INF:
    print('inf')
else:
    print(cost)

Measured memory_bytes: 45276
#include <stdio.h>

int  main(void)
{
	int n,h[200];
	
	int count=0;
	int max=-1;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		
		scanf("%d",&(h[i]));
		
	}
	
	for(int i=0;i<n;i++){
		
		if(max<=h[i]){
			
			max=h[i];
			count++;
			
		}
		
	}
	
	printf("%d\n",count);
	
	return 0;

}

Measured memory_bytes: 128
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Measured memory_bytes: 120044
#include <iostream>
using namespace std;
int main()
{
	int P[1000000] = {};
	int c = 0, j, k;
	for (k = 2; k < 1000000; ++k){
		if (P[k] == 0){
			++c;
			for (j = 2; j * k < 1000000; ++j)
				P[j * k] = -1;
		}
		P[k] = c;				
	}
	while (cin >> k)
		cout << P[k] << "\n";
	return 0;
}

Measured memory_bytes: 5072
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int n, d;
    cin >> n >> d;

    double ans;
    ans = ceil(double(n) / (2*d + 1));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll x;
    cin >> x;

    // 最小回数にするためには、最初が5 -> 6 -> 5 -> 6と続く
    ll ans;
    if (x <= 6)
    {
        ans = 1;
    }
    else if (x > 6 && x <= 11)
    {
        ans = 2;
    }
    else
    {
        ans += x / 11;
        x %= 11;
        if (x == 0)
        {
            ans *= 2;
        }
        else if (x != 0 && x <= 6)
        {
            ans = ans * 2 + 1;
        }
        else
        {
            ans = ans * 2 + 2;
        }

        // if (x % 11 == 0)
        // {
        //     ans = x / 11 * 2;
        // }
        // else
        // {
        //     ans = x / 11 * 2 + 1;
        // }
    }
    cout << ans << endl;
    return (0);
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC090_B();
        }

        static void ABC090_B()
        {
            var AB = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var ans = 0;
            for (var i = AB[0]; i <= AB[1]; i++)
            {
                if (i.ToString() == string.Join("", i.ToString().Reverse()))
                    ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

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

int bubbleSort(vector<int>& v) {
    int counter = 0;
    for (int i = 0; i < v.size() - 1; ++i)
        for (int j = v.size() - 1; j > i; --j)
            if (v[j - 1] > v[j]) {
                v[j - 1] = v[j - 1] ^ v[j];
                v[j] = v[j - 1] ^ v[j];
                v[j - 1] = v[j - 1] ^ v[j];

                counter++;
            }
    return counter;
}

void printVector(vector<int>& v, int counter) {
    for (int i = 0; i < v.size(); ++i)
        if (i + 1 != v.size()) {cout << v[i] << " ";}
        else {cout << v[i] << endl;}
    cout << counter << endl;
}

int main() {
    int N, tmp, counter;
    cin >> N;
    vector<int> v;

    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        v.push_back(tmp);
    }

    counter = bubbleSort(v);
    printVector(v, counter);
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  string s;
  cin >> s;
  reverse(ALL(s));
  ll n = SZ(s);
  const ll INF = 1e18;
  vector<vector<ll>> dp(n + 1, vector<ll>(2, INF));
  dp[0][0] = 0;
  REP(i, n) {
    ll c = s[i] - '0';
    chmin(dp[i + 1][0], dp[i][0] + c);
    chmin(dp[i + 1][1], dp[i][0] + 10 - c);
    chmin(dp[i + 1][0], dp[i][1] + c + 1);
    chmin(dp[i + 1][1], dp[i][1] + 9 - c);
  }
  dp[n][1]++;
  // REP(i, n + 1) {
  //   REP(j, 2) { cout << dp[i][j] << " \n"[j == 1]; }
  // }
  cout << min(dp[n][0], dp[n][1]) << endl;
}

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

int main() {
	//cout<<"GfG!";
	long long int n, a[1000000], i, j, k, f = 1 ;
	unsigned long long int tot = 1, M = 1000000007;
	cin>>n;
	for (i = 0; i < n; i++)
	{
	    cin>>a[i]; 
	}
	sort(a, a + n);
	i = 0;  j = 0; 
	while (i < n)
	{
	    if (n == 1)
	    {   break;  }
	    else if (a[i] == 0 && a[i+1] != 0)
	    {
	        i++;   
	    }
	    else if (a[i] == 0 && a[i+1] == 0)
	    {       f = 0;  break;  }
	    else
	    {
	        if (i == n - 1)
	        {       f = 0;  break;  }
	        else if(a[i+1] == a[i] && (a[j+2] - a[j] == 2))
	        {
	            tot = (tot * 2) % M;
	            i += 2;   j += 2;   
	            if (j == n - 2)
	                j = 0;
	                
	        }
	        else
	        {
	            f = 0;  break;
	        }
	    }
	     
	}
	if (f)
	    cout<<tot;
	else
	    cout<<"0";
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void) {
	int n;
	int i,j;
	scanf("%d", &n);
	int a[100];
	for(i=0; i<n; i++) {
		scanf("%d", &a[i]);
	}
	for(i=0; i<n; i++) {
		j=n-i-1;
		printf("%d", a[j]);
		if(i==n-1) putchar('\n');
		else putchar(' ');
	}
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める

//x かけるy　で　x とｙが違う値の時にNoになるかも？
int main(){
    int H,W,A,B;//行、列、行、列
    cin >> H >> W >> A >> B;
    int R = 0; //roopの回数
    rep(i,H){
        int countA = 1;//何列目の出力をしているか。これがAより小さいなら0
        rep(j,W){
            int countB=R/W;//何行目の出力をしているか。これがBより小さいなら0
            //countAがBになったら改行
            if((countA<=A&&countB<B)||(countA>A&&countB>=B)){
                cout<<0;
            }
            else cout<<1;
            countA++;
            if(countA==W+1) cout<<endl;
            R++;
        }
    }
}



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

const long long MXN = 105;
const long long MXK = 100005;
long long dp[MXN][MXK];

int main() {
	
	for (long long i=0; i<MXN; i++) for (long long j=0; j<MXK; j++) dp[i][j] = INT_MAX;
	
	long long n, capacity;
	cin >> n >> capacity;
	long long weights[n], values[n];
	for (long long i=0; i<n; i++) {
		cin >> weights[i] >> values[i];
	}
	
	// dp[i][j] - having considered i items with a value of j, what is the min weight of items taken?
	dp[0][0] = 0; // 0 items with value of 0 have 0 weight
	for (long long i=1; i<MXK; i++) {
		dp[0][i] = INT_MAX; // 0 items with value > 0 have infinite weight
	}
	for (long long i=1; i<=n; i++) {
		// consider the ith item
		for (long long j=0; j<MXK; j++) {
			// consider getting j value
			// either must have taken the item or not
			dp[i][j] = INT_MAX;
			long long val = values[i-1];
			if (j >= val) {
				// if the value is less or equal to attained value
				dp[i][j] = min(dp[i][j], weights[i-1] + dp[i-1][j - val]);
			}
			// or from not taking the item
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
	}
	
	long long mxval = 0;
	for (long long i=0; i<=n; i++) {
		for (long long j=0; j<MXK; j++) {
			if (dp[i][j] <= capacity) {
				mxval = max(mxval, j);
			}
		}
	}
	cout << mxval << endl;
	
	
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
ll d, a;

struct node {
  ll x,h;
  bool operator<(const node& o) const {
    return x < o.x;
  }
};

vector<node> v;

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

  cin>>n>>d>>a;
  for (int i=0; i<n; i++) {
    ll x,h; cin>>x>>h;
    v.push_back({x,h});
  }

  sort(v.begin(), v.end());
  ll ans = 0;
  ll prefix = 0;
  set<pair<ll,ll>> st;
  for (int i=0; i<n; i++) {
    while (!st.empty() && st.begin()->first < v[i].x) {
      prefix -= st.begin()->second;
      st.erase(st.begin());
    }
    ll need = max(0LL, (v[i].h-(prefix*a)+a-1)/a);
    ans += need;
    
    prefix += need;
    st.insert({v[i].x+d+d, need});
  }

  out(ans);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0;i<N;++i){
    cin >> p.at(i);
  }
  int count = 0;
  for(int i=0;i<N;++i){
    if(p.at(i) != i+1){
      ++count;
    }
  }
  if(count == 0 || count == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
list = ['a' ,'b', 'c', 'd', 'e', 'f' , 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 's', 't', 'u', 'v', 'w', 'x', 'y','z']
n = input()
i = 0
while n != list[i]:
  i += 1
i += 1
print(list[i])

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

int main(void) {
    string S;
    char last;
    int lcnt,rcnt;
    int *pcnt;
    cin >> S;

    int N = S.size();
    vector<int> sq(N,0);
    // RLの並びの偶奇を見る。 LRで分断される
    lcnt = 0; rcnt = 1;
    pcnt = &rcnt;
    last = 'R';
    for(int i=1;i<S.size();i++) {
        if(last != S[i]) {
            if(last == 'L'){
                //計算 今のポジション
                sq[i-lcnt] += rcnt / 2;
                sq[i-lcnt] += (lcnt % 2) ? (lcnt / 2) + 1 : lcnt / 2; 
                sq[i-lcnt-1] += (rcnt % 2) ? (rcnt/2) + 1 : rcnt / 2; 
                sq[i-lcnt-1] += lcnt / 2; 
                lcnt = 0;rcnt = 0;
                pcnt = &rcnt;
            } else {
                pcnt = &lcnt;
            }
        }
        (*pcnt)++;
        last = S[i];
    }

    // 最後にも計算
                sq[N-lcnt] += rcnt / 2;
                sq[N-lcnt] += (lcnt % 2) ? (lcnt / 2) + 1 : lcnt / 2; 
                sq[N-lcnt-1] += (rcnt % 2) ? (rcnt/2) + 1 : rcnt / 2; 
                sq[N-lcnt-1] += lcnt / 2; 
    for(int i=0;i<N;i++) {
        cout << sq[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    if(b % a == 0)
        cout << a + b;
    else
        cout << b - a;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input().split()
a = [int(m) for m in a]
li = []
cnt = 0
if abs(min(a)) <= abs(max(a)):
    for i in range(1, n):
        while True:
            if a[i - 1] <= a[i]:
                break
            else:
                li.append([a.index(max(a)) + 1, i + 1])
                a[i] += max(a)
                cnt += 1

else:
    for i in range(1, n):
        while True:
            if a[-i] >= a[-i-1]:
                break
            else:
                li.append([a.index(min(a)) + 1, n - i])
                a[-i-1] += min(a)
                cnt += 1


print(cnt)
for i in range(cnt):
    print(li[i][0], li[i][1])

Measured memory_bytes: 3188
#include <stdio.h>

void Insertation_Sort(int a[], int m) {

	int i, j, v;

	for (i = 1; i < m; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

int main(void) {
	int s[100000], t[50000];
	int i, j;
	int n, m, count = 0, mark = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}

	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &t[i]);
	}

	Insertation_Sort(t, m);

	for (i = 0; i < m; i++) {
		for (j = mark; j < n; j++) {
			if (t[i] == s[j]) {
				mark = j;
				count++;
				break;
			}
			if (t[i] < s[j]) {
				mark = j;
				break;
			}
		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2304
s=input()
A=int(s[:2])
B=int(s[2:])
if (A>12 or A==0) and 0<B<=12:print("YYMM")
elif 0<A<=12 and (B>12 or B==0):print("MMYY")
elif 0<A<=12 and 0<B<=12:print("AMBIGUOUS")
else:print("NA")

Measured memory_bytes: 3060
dice =[2,5,3,4,1,6]
def rot(d, k)
  case(k)
  when 0,2
    3.times{rot(d, k+1)}
  when 1
    d[1], d[5], d[0], d[4]= d[4], d[1], d[5], d[0]
  when 3
    d[3], d[5], d[2], d[4] = d[4], d[3], d[5], d[2]
  else
    d[0], d[2], d[1], d[3] = d[3], d[0], d[2], d[1]
  end
end

loop do
  n=gets.to_i
  break if n == 0
  map = Hash.new([])
  n.times do
    t,f = gets.split.map(&:to_i)
    d = dice.clone
    catch(:found) do
      6.times do |i|
        4.times do
          rot(d, 4)
          throw :found if d[2] == f && d[4] == t
        end
        rot(d, i.even? ? 0 : 2)
      end
    end
    x,y = 0,0
    loop do
      map[[x,y]] += [d[4]]
      dx,dy = [-1,1,0,0],[0,0,1,-1]
      mv, dv = 0, -1
      for i in 0..3
        if map[[x+dx[i],y+dy[i]]].size < map[[x,y]].size - 1 && d[i] > dv
          dv, mv = d[i],i
        end
      end
      break if dv <= 3
      map[[x,y]].pop
      rot(d,mv)
      x, y = x + dx[mv], y + dy[mv]
    end
  end
  res = [0,0,0,0,0,0]
  map.each {|k,v| res[v.last - 1] += 1 } 
  puts res.join(' ')
end

Measured memory_bytes: 6152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(N,0);
  
  for(int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
  }
  
  for(int i=0; i<M; i++){
    for(int j=0; j<N; j++){
      if(a.at(i) == j+1)
      	c.at(j)++;
      if(b.at(i) == j+1)
        c.at(j)++;
    }
  }
  for(int j=0; j<N; j++){
    cout << c.at(j) << endl;
  }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=0
for i in range(n):
	for j in range(i,n+1):
		if len(v[:i])+len(v[j:])>k:
			continue	
		p=sum(v[:i])+sum(v[j:])
		minus=[]
		for x in v[:i]:
			if x<0:
				minus.append(x)
		for x in v[j:]:
			if x<0:
				minus.append(x)
		minus.sort()
		for l in range(min(len(minus),k-(len(v[:i])+len(v[j:])))):
			p-=minus[l]
		ans=max(ans,p)
print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    cin >> n >> x;
    int l[n];
    for(int i=0;i<n;i++) cin >> l[i];
    int now=0;
    int res=1;
    for(int i=0;i<n;i++)
    {
        now+=l[i];
        if(now<=x) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

/* Dise??¢??°?????£?¨? */
void Dice(char p, int []);
/* Count??¢??°?????£?¨? */
int Count(int[]);
 
int main(void){

    int d[6], d2[6], i, flg = 0;
    char str[2][4] = { "No","Yes" };

    for (i = 0; i < 6; i++)
    	scanf("%d", &d[i]);
    for (i = 0; i < 6; i++)
    	scanf("%d", &d2[i]);
    if (Count(d) >= 10){
    	printf("Yes\n");
    	return 0;
    	}
    if (d[0] == d2[0]);
    else if (d[5] == d2[0]) Dice('N', d), Dice('N', d);
    else if (d[1] == d2[0]) Dice('N', d);
    else if (d[4] == d2[0]) Dice('S', d);
    else if (d[2] == d2[0]) Dice('W', d);
    else if (d[3] == d2[0]) Dice('E', d);
    if (d[1] == d2[1]);
    else if (d[4] == d2[1]) Dice('L', d), Dice('L', d);
    else if (d[2] == d2[1]) Dice('R', d);
    else if (d[3] == d2[1]) Dice('L', d);
    for (i = 3; i < 6; i++) {
        if (d[i] != d2[i]) break;
        if(i==5) flg = 1;
    }
    printf("%s\n", str[flg]);
    return 0;
}
 
void Dice(char p, int d[]) {
    int tmp;
    if (p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
    if (p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
    if (p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
    if (p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
    if (p == 'L') { tmp = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = tmp; }
    if (p == 'R') { tmp = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp; }
}
 
int Count(int d[]){
    int cnt = 0, i, j;
    for (i = 0; i < 5; i++) {
        for (j = i + 1; j < 6; j++)
            if (d[i] == d[j])++cnt;
    }
    return cnt;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int n;
  cin >> n;

  vector<string> s(n);

  for (auto &i : s) {
    cin >> i;
  }

  map<string, int> cnt;
  for (auto &i : s) {
    cnt[i]++;
  }

  int mx = 0;

  for (auto &i : cnt) {
    mx = max(mx, i.second);
  }

  set<string> ans;

  for (auto i = 0; i < n; ++i) {
    if (cnt[s[i]] == mx) {
      ans.insert(s[i]);
    }
  }

  print(ans.begin(), ans.end());

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> H[i];
    ll inf = 1e18;
    vector<ll> dp(N+1, inf);
    dp[1] = 0;
    for (int i = 2; i <= N; i++) {
        for (int j = 1; (j <= K && i-j >= 1); j++) {
            dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]));
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,W,H,L;
vector<P> t;

bool check(P p,int a){
  if(p.first<p.second)
    return (p.first<=a&&a<=p.second);
  return (p.first<=a||a<=p.second);
}
int solve(int si){
  int res=1,last=t[si].second;
  for(int i=si;i<si+N;i++){
    if(check(t[i],last)) continue;
    res++;
    last=t[i].second;
  }
  return res;
}
int main(){
  cin>>N>>W>>H;
  L=W+W+H+H;
  for(int i=0;i<N;i++){
    int x,y,a,b;
    char ch;
    cin>>x>>y>>ch;
    if(ch=='N'){
      a = (x+y+L)%L;
      b = (H+x-y+H)%L;
    }
    if(ch=='E'){
      a = (H+H-y+x+L)%L;
      b = (L-y-x)%L;
    }
    if(ch=='S'){
      a = (L-x-y+L)%L;
      b = (L-x+y)%L;
    }
    if(ch=='W'){
      a = (y-x+L)%L;
      b = (y+x)%L;
    } 
    t.push_back(P(b,a));
  }
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++) t.push_back(t[i]);
  for(int i=0;i<N+N;i++) swap(t[i].first,t[i].second);
  int ans = N;
  for(int i=0;i<N;i++)ans = min(ans,solve(i));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3124
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
for i in range(1000):
    tmp = str(i).zfill(3)
    cnt = 0
    for j in range(N):
        if S[j] == tmp[cnt]:
            cnt += 1
            if cnt == 3:
                ans += 1
                break
print(ans)

Measured memory_bytes: 78848
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp
#include <iostream>
using namespace std;

void swap(int A[],int i,int j){
  int buf = A[j];
  A[j] = A[i];
  A[i] = buf;
}

int partition(int A[], int l, int r){
  const int x = A[r]; //????????¨?????????
  int i = l-1; //??§???????????????????????¨??????????????????-1
  for(int j = l; j < r; j++){
    //j?????????????????£???????????¨??????????????????????????¨????????????
     if (A[j] <= x){
       i += 1;
       //??´??????????????????????????¨???
       swap(A,i,j);
     }
  }
  swap(A,i+1,r);
  return i+1;
}


int main(){
  int n;
  cin >> n;
  int S[n];
  for(int i=0; i<n; i++){
    cin >> S[i];
  }//????????????????????????

  int mark = partition(S,0,n-1);
  for(int i=0; i<mark; i++){
    cout << S[i] << " ";
  }
  cout << "[" << S[mark] << "] ";
  for(int i=mark+1; i<n-1; i++){
    cout << S[i] << " ";
  }
  cout << S[n-1] << endl;
  return 0;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int H = int.Parse(s[2]);
            int M = int.Parse(s[3]);

            double hour = (Math.PI * 2 / 720) * ((H * 60) + M);
            double minute = (Math.PI * 2 / 60) * ((H * 60) + M);

            double rad = Math.Abs(hour - minute);

            double answer = Math.Sqrt(Math.Pow(A, 2) + Math.Pow(B, 2) - 2 * A * B * Math.Cos(rad));

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 27908
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main() {
    char str[30];
    int hash[30];
    
    scanf("%s", str);
    
    for ( int i = 0; i <= 26; i++ ) {
        hash[i] = 0;
    }
    
    for ( int i = 0; str[i] != '\0'; i++ ) {
        hash[str[i] - 'a']++;
        if ( hash[str[i] - 'a'] > 1 ) {
            cout << "no" << endl;
            return 0;
        }
    }
    
    cout << "yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

typedef vector<int> vi;
typedef queue<int> qi;

int h(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    return (a - 1) * (a - 2) / 2 + b - 1;
}

int main() {
    int n;
    cin >> n;
    int m = n * (n - 1) / 2;
    vi e[m];
    for (int i = 1; i <= n; i++) {
        int la;
        cin >> la;
        for (int j = 1; j < n - 1; j++) {
            int a;
            cin >> a;
            e[h(i, la)].push_back(h(i, a));
            la = a;
        }
    }

    int d[m];
    memset(d, 0, sizeof(d));
    for (int i = 0; i < m; i++) {
        for (int j : e[i]) {
            d[j]++;
        }
    }

    int dp[m];
    memset(dp, 0, sizeof(dp));
    qi q;
    for (int i = 0; i < m; i++) {
        if (d[i] == 0) {
            q.push(i);
            dp[i] = 1;
        }
    }

    int ans = 0;
    while (!q.empty()) {
        int x = q.front();
        q.pop();

        for (int y : e[x]) {
            d[y]--;
            dp[y] = max(dp[y], dp[x] + 1);
            ans = max(ans, dp[y]);
            if (d[y] == 0) {
                q.push(y);
            }
        }
    }

    for (int i = 0; i < m; i++) {
        if (dp[i] == 0) {
            ans = -1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N=1e5+10;
int n,x[N],y[N],t[N],dx,dy,dt,d;
bool vld;




void solve()
{
	cin>>n;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	vld=1;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
		dx=abs(x[i]-x[i-1]);
		dy=abs(y[i]-y[i-1]);
		dt=t[i]-t[i-1];
		d=dt-dx-dy;
		if(d<0||d%2==1)vld=0;
	}
	if(vld)cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>



int main(void)
{

   int a,b,c,d;

   scanf("%d%d%d",&a,&b,&c);

   d = b / a;



   if (d < c){
      printf("%d\n",d);
      }

   else{ 
         printf("%d\n",c);
        }
   return 0;
}

Measured memory_bytes: 128
import itertools
n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]

ans = 100000000000000
for li in itertools.product(range(4), repeat=n):
  tmp = [[] for i in range(4)] #tmp[0]がaの竹、tmp[1]がbの竹、tmp[2]がcの竹、tmp[3]は使わない竹
  for i in range(len(li)):
    tmp[li[i]].append(l[i])
  if len(tmp[0])*len(tmp[1])*len(tmp[2]):
    ans = min(ans,(len(tmp[0])-1)*(10)+(len(tmp[1])-1)*(10)+(len(tmp[2])-1)*(10)+abs(sum(tmp[0])-a)+abs(sum(tmp[1])-b)+abs(sum(tmp[2])-c))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;
const ll INF = 10000000000000LL;

ll dist[302][302];
ll dist_backup[302][302];

struct edge{
    int a, b, cost;
    edge(int a, int b, int cost): a(a), b(b), cost(cost) {}
    bool operator<(const edge& right) const {
        return cost < right.cost;
    }
};

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

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> dist[i][j];
            dist_backup[i][j] = dist[i][j];
        }
    }

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

    vector<edge> E;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(dist[i][j] != dist_backup[i][j]){
                cout << -1 << endl;
                return 0;
            }
            E.emplace_back(i, j, dist[i][j]);
            dist[i][j] = INF;
        }
    }

    for(int i=0;i<N;i++){
        dist[i][i] == 0;
    }

    sort(E.begin(), E.end());
    ll ans = 0;
    for(edge e : E){
        if(dist[e.a][e.b] <= e.cost) continue;
        ans += e.cost;
        dist[e.a][e.b] = e.cost;
        dist[e.a][e.b] = e.cost;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                dist[i][j] = min(dist[i][j], dist[i][e.a] + e.cost + dist[e.b][j]);
                dist[i][j] = min(dist[i][j], dist[i][e.b] + e.cost + dist[e.a][j]);
                dist[j][i] = dist[i][j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
#define MAX (int)(2e6+5)
#define PB push_back
#define MP make_pair
#define ll long long
#define pii pair<long long,long long>
#define sz(a) (int)a.size()
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fore(i,l,n) for(int i=int(l);i<int(n);i++)
#define clr(a) memset(a,0,sizeof(a))
#define MOD (int)(1e7+7)
#define INF (long long)(1e18)

using namespace std;

int main()
{
    //freopen("tt.txt","r",stdin);
    int test=1,i=0,n,m;
    //si(test);
    while(test--){
        int n,m;
        sii(n,m);
        int ar[n+5];
        fore(i,1,n+1) si(ar[i]);
        int x,y;
        vector<int>adj[n+5];
        forn(i,m){
            sii(x,y);
            adj[x].PB(y);
            adj[y].PB(x);
        }
        int cnt=0;
        fore(i,1,n+1){
            bool tr=true;
            forn(j,sz(adj[i])){
                int u=adj[i][j];
                if(ar[i]<=ar[u]) tr=false;
            }
            if(tr) cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 9220
a=["Sunny", "Cloudy", "Rainy"]

S=input()

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]
  
idx=func1(a,S)[0]

if idx==2:
  ans=0
else:
  ans=idx+1

print(a[ans])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;

    // 文字列の入力
    char s[100000];
    cin >> s;

    for (int i = 0; s[i] != 0x00; i++) {
        s[i] += n;
        if (s[i] > 0x5a) s[i] -= 26;
    }

    cout << string(s) <<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.back() == 's') {
    S += "es";
  } else {
    S += 's';
  }
  cout << S << endl;
  return 0;
}


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

using namespace std;

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef V<pll> vpll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define MAXN 100001

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

void solve()
{
	int n , k , sum = 0;
	cin >> n >> k;

	int a[n];
	f(i, n) cin >> a[i];

	sort(a, a + n);

	for (int i = 0 ; i < k ; i++)
		sum += a[i];

	cout << sum << "\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define A 1000
int main(){
  int i,j,k,n;
  int a[A];
  int key;
  scanf("%d",&n);
  for(i = 0;i <= n-1; i++){
    scanf("%d",&a[i]); 
  }
  for(k=0;k <= n-1 ;k++){
    if(k==n-1){
      printf("%d\n",a[k]);
    }
    else{
      printf("%d ",a[k]);
    }
  }
  for(i=1;i <= n-1; i++){
    key = a[i];
    j = i-1;
    while(j >= 0 && a[j] > key){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=key;
    for(k=0;k<=n-1;k++){
      if(k==n-1){
	printf("%d\n",a[k]);
      }
      else{
	printf("%d ",a[k]);
      }
    }
  }
  return 0;
}
    




Measured memory_bytes: 2080