akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

vector<PII> g[105];
int d[105][1010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n, m, c;
    cin >> n >> m >> c;
    if(!n) break;
    REP(i, n) g[i].clear();
    REP(i, m) {
      int p, q, r;
      cin >> p >> q >> r;
      p--, q--;
      g[p].PB({q, r});
    }

    priority_queue<VI, VVI, greater<VI>> que;
    REP(i, n) REP(j, m) d[i][j] = LLINF;
    d[0][0] = 0;
    que.push({d[0][0], 0, 0});

    while(que.size()) {
      VI v = que.top(); que.pop();
      int cost = v[0], ver = v[1], cut = v[2];
      if(cost > d[ver][cut]) continue;
      if(c < d[ver][cut]) continue;
      for(auto e: g[ver]) {
        // 0にしない
        if(d[ver][cut] + e.second <= c && d[e.first][cut] > d[ver][cut] + e.second) {
          d[e.first][cut] = d[ver][cut] + e.second;
          que.push({d[e.first][cut], e.first, cut});
        }
        // 0にする
        if(d[e.first][cut+1] > d[ver][cut]) {
          d[e.first][cut+1] = d[ver][cut];
          que.push({d[e.first][cut+1], e.first, cut+1});
        }
      }
    }

    int ret = LLINF;
    REP(i, m+1) if(d[n-1][i] <= c) chmin(ret, i);
    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 9096
#include <cstdio>

int x, y;
int a[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

int main(){
	scanf("%d %d", &x, &y);
	if(a[x] == a[y]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
list = []
for i in range(5):
    a = int(input())
    list.append(a)
list1 = []
for i in range(5):
    list1.append(list[i]%10)

min = 10
min_ind = 0
for i in range(5):
    if min > list1[i] > 0:
        min = list1[i]
        min_ind = i
cnt = []
for i in range(5):
    if i != min_ind:
        for j in range(1,14):
            if list[i] <= 10 * j:
                cnt.append(10*j)
                break
    else:
        cnt.append(list[i])
print(sum(cnt))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n, m;
	cin>>n>>m;
	int a[n], b=0;
	rep(i, n){
		cin>>a[i];
		b+=a[i];
	}
	int c=0;
	rep(i, n){
		if(a[i]>=(b+4*m-1)/(4*m)){
			c++;
		}
	}
	if(c>=m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  print(a+b+c-max(a, max(b,c)));
}


Measured memory_bytes: 256
card = Array.new(3){gets.split(" ").map(&:to_i)}
n = gets.to_i
nums = Array.new(n){gets.to_i}
i = 0
while i <= 2
  j = 0
  while j <=  2
    if nums.include?(card[i][j])
      card[i][j] = "○"
    end
    j += 1
  end
  i += 1
end
if (card[0][0] == "○" && card[0][1] == "○" && card[0][2] == "○") || 
    (card[1][0] == "○" && card[1][1] == "○" && card[1][2] == "○") ||
    (card[2][0] == "○" && card[2][1] == "○" && card[2][2] == "○") ||

    (card[0][0] == "○" && card[1][0] == "○" && card[2][0] == "○") ||
    (card[0][1] == "○" && card[1][1] == "○" && card[2][1] == "○") ||
    (card[0][2] == "○" && card[1][2] == "○" && card[2][2] == "○") ||

    (card[0][0] == "○" && card[1][1] == "○" && card[2][2] == "○") ||
    (card[0][2] == "○" && card[1][1] == "○" && card[2][0] == "○")
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
      char c;
      cin>>c;
      if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
      cout<<"vowel";
      else
      cout<<"consonant";
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3608
fun main() {
    val (a, b, c) = next3Int()
    val k = nextInt()
    when {
        a > k -> println(k)
        a + b > k -> println(a)
        else -> println(a - k + (a + b))
    }
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))

Measured memory_bytes: 36288
// In the name of God

#include <bits/stdc++.h>

using namespace std;

vector<int> v[3];

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	for(int i = 0; i < n; i++) {
		if(s[i] == 'R') v[0].push_back(i);
		if(s[i] == 'G') v[1].push_back(i);
		if(s[i] == 'B') v[2].push_back(i);
	}

	auto solve = [&](vector<int> &v1, vector<int> &v2, vector<int> &v3) {
		// take i, j from v1 and v2
		// take k from v3
		long long ret = 0;
		for(int i : v1) {
			for(int j : v2) {
				if(j < i) continue;
				ret += v3.end() - lower_bound(v3.begin(), v3.end(), j);
				if(j + (j - i) < n && s[j + (j - i)] != s[j] && s[j + (j - i)] != s[i]) ret--;
			}
		}
		return ret;
	};

	long long ans = 0;

	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			if(i == j) continue;
			ans += solve(v[i], v[j], v[3 - i - j]);
		}
	}

	cout << ans;
	

	return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout << "Yes" << endl;
  }
  else if (b == c && a != c) {
    cout << "Yes" << endl;
  }
  else if (a == c && a != b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll lcm(ll a, ll b) {
	return (a*b)/gcd(a,b) ; 
}
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}
void read(vt<ld> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

bool prime(ll t) {
	for(ll i  =2 ; i*i <= t ; ++i) {
		if(t%i==0) 
			return 0 ; 
	}
	return 1 ; 
}
bool cmp(pii &a , pii &b) {
	if(a.ss == b.ss) 
		return a.ff > b.ff ; 
	return a.ss < b.ss ; 
}

// ==========OKAY==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int n , m  ; 
	cin >> n >> m ; 
	int a[m+1][2] ; 
	bool ok = 1 ;
	rep(i,0,m) {
		cin >> a[i][0] >> a[i][1] ; 
		if(a[i][0] == 0 || a[i][0] > n){
			ok=0;
		}
	}
	if(!ok){
		cout<<-1 ; 
		return 0 ; 
	}
	map<int,int> dig ;
	rep(i,1,n+1) {
		dig[i] = -1 ; 
	}
	rep(i,0,m) {
		if(dig[a[i][0]] == -1) {
			dig[a[i][0]] = a[i][1] ; 
		} else {
			if(a[i][1] != dig[a[i][0]]) {
				cout << -1 ; 
				return 0; 
			}
		}
	}
	if(dig[1] == -1 && n == 1) {
		cout << 0 ; 
		return 0 ; 
	}
	rep(i,1,n+1) {
		if(dig[i] == -1 && i == 1) {
			dig[i] = 1 ; 
		} 
		else if(dig[i]==-1) {
			dig[i]=0; 
		}
	}
if(n==1) {
cout << dig[1] ; 
return  0 ; 
}

	if(dig[1] == 0 ) {
		cout << -1 ;
		return 0 ; 
	}
	rep(i,1,n+1) {

		cout << dig[i] ; 
	}


 	return 0 ; 
}

Measured memory_bytes: 3620
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (n, m) = (int(), int());
    let k = 1900 * m + 100 * (n - m);
    let mut l = (1..(m + 1)).fold(1, |x, i| x * 2);
    println!("{}", k * l);
}


Measured memory_bytes: 4352
S = list(input())
T = list(input())
conv = {}
flag = 1
for s, t in zip(S, T):
    if s in conv and conv[s] != t:
        flag = 0
        break
    conv[s] = t
end = conv.values()
if len(end) != len(set(end)):
    flag = 0
print('Yes' if flag else 'No')

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

int main() {
  int A,B,X,i;
  cin >> A >> B;
  i = 0;
  X = 0;
  while(i < 2){
    if(A >= B){
      X = X + A;
      A = A - 1;
    }
    else if(A < B){
      X = X + B;
      B = B - 1;
    }
    i++;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)

	for i := range a {
		a[i] = scanInt()
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	ans := 1
	for _, v := range a {
		ans *= v
		if ans > 1000000000000000000 || ans < v {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue

int n;
string s;
int a[maxn], b[maxn], ans = 1e9;
int main(){
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W'){
            a[i - 1]++;
        }
        else {
            b[i + 1]++;
        }
    }
    for(int i = 0; i < s.size(); i++){
        b[i] += b[i - 1];
    }
    for(int i = s.size() - 1; i >= 0; i--){
        a[i] += a[i + 1];
    }
    for(int i = 0; i < n; i++){
        ans = min(ans, (n - 1) - (a[i] + b[i]));
    }
    cout << ans;
}


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

namespace ABC165C
{
    class Program
    {
        static int N;
        static int M;
        static int Q;

        static int[] ai;
        static int[] bi;
        static int[] ci;
        static int[] di;

        static void Main(string[] args)
        {
            int[] NMQ = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NMQ[0];
            M = NMQ[1];
            Q = NMQ[2];

            ai = new int[NMQ[2]];
            bi = new int[NMQ[2]];
            ci = new int[NMQ[2]];
            di = new int[NMQ[2]];
            for (int i = 0; i < NMQ[2]; i++)
            {
                int[] abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ai[i] = abcd[0];
                bi[i] = abcd[1];
                ci[i] = abcd[2];
                di[i] = abcd[3];
            }

            int ans = SimulateA(new List<int>());

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static private int SimulateA(List<int> A)
        {
            if (A.Count == N)
            {
                int ans = 0;

                //判定の計算して返す
                for (int i = 0; i < Q; i++)
                {
                    if (A[bi[i] - 1] - A[ai[i] - 1] == ci[i]) ans += di[i];
                }

                return ans;
            }

            int max = 0;
            int start = 0;
            if (A.Count > 0) start = A.Last();

            for (int i = start; i < M; i++)
            {
                var temp = new List<int>(A);
                temp.Add(i);
                int a = SimulateA(temp);
                if (a > max) max = a;
            }

            return max;
        }



    }
}


Measured memory_bytes: 23152
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
*/
using namespace std;
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set_ll tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
#define tr(container,it) for(typeof(container).begin() it=container.begin();it!=container.end();it++)
#define fast ios_base::sync_with_stdio(false);
#define ll long long int
#define sz(x) (int)(x.size())
#define all(a) a.begin(),a.end()

const ll mod=1e9+7;
vector<int> ar[100001];
vector<int> dp(100001,-1);
void solve(int n)
{
    int i;
    if(ar[n].empty())
    {
        dp[n]=0;
        return;
    }
    for(i=0;i<(int)(ar[n].size());i++)
    {
        if(dp[ar[n][i]]==-1)
            solve(ar[n][i]);
        dp[n]=max(dp[n],dp[ar[n][i]]+1);
    }
    return;
}

int main()
{
    fast
    int i,n,m,x,y,ans=0,k;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        ar[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        if(dp[i]==-1)
            solve(i);
        ans=max(dp[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}
  


Measured memory_bytes: 11052
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a, b;
    std::cin >> a >> b;
    std::vector<std::vector<int>> g;
    for (int i = 0; i < 100; i++) g.push_back(std::vector<int>(100, 1 - i / 50));
    for (int i = 0; i < a - 1; i++) g[i / 50 * 2][i % 50 * 2] = 0;
    for (int i = 0; i < b - 1; i++) g[99 - i / 50 * 2][i % 50 * 2] = 1;
    std::cout << "100 100\n";
    for (auto &w : g) {
        for (auto e : w) std::cout << (e ? '#' : '.');
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    static int k = 0;
    static List<int> ans = new List<int>();
    public static void Main()
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        k = int.Parse(input[2]);
        int count = 0;
        for(int i=1;i<=Math.Min(a,b);i++)
        {
            if((a%i==0)&&(b%i)==0)
            {
                ans.Add(i);
            }

            if (count == k)
                break;
        }

        
        Console.Write(ans[ans.Count-k]);
          
    }

    static int GCD(int a, int b)
    {
        if (a == 0)
            return b;
        
        return GCD(b % a, a);
    }



}



Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 10000
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end
using namespace std;
typedef pair<int, int> P;
int main(){

    vector<char>n1(101,0);
    vector<char>n2(101,0);
    vector<char>n3(101,0);
    vector<char>ex(1);
    ex.erase(ex.begin());
    if(ex.empty())
       // cout << "YES" << endl;
    rep(i,3){
        char temp[100];
        cin >> temp;
        int l =(int)strlen(temp);
        rep(j,l) {if(i == 0) {n1[j] = temp[j];}
        if(i == 1) {n2[j] = temp[j];}
        if(i == 2) {n3[j] = temp[j];}
        }
    }
    char del = n1[0]; int key;
    n1.erase(n1.begin());
    while(true){
        if(del == 'a')
        {
            if(n1[0] == 0)
            {key = 1; break;}
            del = n1[0];
            n1.erase(n1.begin());

                
        }
        if(del == 'b')
        {
            if(n2[0] == 0)
            {key = 2;break;}
            del = n2[0];
            n2.erase(n2.begin());

        }
        if(del == 'c')
        {
            if(n3[0] == 0)
            {key = 3; break;}
            del = n3[0];
            n3.erase(n3.begin());
        }
        
    }
    if(key == 1)
        cout << "A" << endl;
    else if(key == 2)
        cout << "B" << endl;
    else
        cout << "C" << endl;

}

Measured memory_bytes: 256
from math import ceil

n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]


def f(x):
    cnt = 0
    for e in h:
        cnt += max(0, ceil((e - b * x) / (a - b)))

    if cnt > x:
        return False

    return True


l = 0
r = ceil(max(h) / b)
while r - l > 1:
    mid = (l + r) // 2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)


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

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  ll a = t1 * a1 - t1 * b1;
  ll b = t2 * a2 - t2 * b2;
  if (a > 0) {
    a *= -1;
    b *= -1;
  }
  if (a + b < 0) cout << 0 << endl;
  else if (a + b == 0) cout << "infinity" << endl;
  else {
    ll s = -a / (a + b);
    ll t = -a % (a + b);
    if (t == 0) cout << s * 2 << endl;
    else cout << s * 2 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int x = sc.nextInt(), y = sc.nextInt();
            if(x==0&&y==0) {
                break;
            }
            if(x > y) {
                System.out.printf("%d %d\n", y, x);
            } else {
                System.out.printf("%d %d\n", x, y);
            }
        }
    }
}


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

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b){
  ll p=1;
  for(int i=0;i<b;i++){
    p*=a;
  }
  return p;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int h,w;
  cin>>h>>w;
  int a[h+1][w+1];
  for(i=1;i<=h;i++)for(j=1;j<=w;j++)cin>>a[i][j];
  for(i=1;i<=h;i++)for(j=1;j<=w;j++)a[i][j]=a[i][j]%2;
  int n=h*w;
  int p[n],q[n],r[n],s[n];
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(a[i][j]==1){
        if(j!=w){
          p[cnt]=i;
          q[cnt]=j;
          r[cnt]=i;
          s[cnt++]=j+1;
          a[i][j+1]=1-a[i][j+1];
        }else if(i!=h){
          p[cnt]=i;
          q[cnt]=j;
          r[cnt]=i+1;
          s[cnt++]=j;
          a[i+1][j]=1-a[i+1][j];
        }
      }
    }
  }
  cout<<cnt<<endl;
  for(i=0;i<cnt;i++){
    cout<<p[i]<<" "<<q[i]<<" "<<r[i]<<" "<<s[i]<<endl;
  }
}

Measured memory_bytes: 5120
using System;

class ITP1_8_A
{
  static void Main()
  {
    char[] s = Console.ReadLine().ToCharArray();
    for (int i = 0; i < s.Length; i ++)
    {
      if (char.IsUpper(s[i])) s[i] = char.ToLower(s[i]);
      else s[i] = char.ToUpper(s[i]);
    }
    Console.WriteLine(s);
  }
}



Measured memory_bytes: 17828
from collections import defaultdict
from heapq import heappush, heappop

def main():
    #Read stdin
    fl = input().split(" ")
    V = int(fl[0])
    E = int(fl[1])
    R = int(fl[2])
    #Adjacency list
    G = defaultdict(list)
    for i in range(int(E)):
        s, t, w = [int(x) for x in input().split(" ")]
        G[s].append((t,w))

    #initialized
    d = {}
    INF = float('inf')
    #INF = 10001
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = [R]
    while q:
        u = heappop(q)
        for v in G[u]:
            if d[v[0]] > d[u] + v[1]:
                d[v[0]] = d[u] + v[1]
                heappush(q, v[0])

    for k in d.keys():
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])

if __name__ == '__main__':
    main()

Measured memory_bytes: 111892
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define ll long long
const int N = 2e6 + 15;
int main(){
	int k;
	cin >> k;
	string s = "1";
	while (--k) {
		int n = s.length();
		//trace(k, s, n);
		int ok = 0;
		for (int i = n-1; i > 0; --i) {
			if (s[i] <= s[i-1] && s[i] != '9') {
				s[i]++;
				for (int j = i+1; j < n; ++j) {
					s[j] = s[j-1]-1;
					if (s[j] < '0') {
						s[j] = '0';
					}
				}
				ok = 1;
				break;
			}
		}
		if (ok) {
			continue;
		}
		if (s[0] != '9') {
			char f = s[0];
			s[0] = f+1;
			for(int i = 1; i < n; ++i) {
				s[i] = s[i-1]-1;
				if (s[i] < '0') {
					s[i] = '0';
				}
			}
			continue;
		}
		s.assign(n+1, '0');
		s[0] = '1';
		
	}
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 256
il1 = [int(k) for k in input().split()]
N = il1[0]
M = il1[1]
H = [int(k) for k in input().split()]
result = [True]*N
for m in range(M):
    il = [int(k) for k in input().split()]
    A = il[0]-1
    B = il[1]-1
    if (H[A] < H[B]):
        result[A] = False
    elif (H[A] > H[B]):
        result[B] = False
    else:
        result[A] = False
        result[B] = False

print(result.count(True))


Measured memory_bytes: 19992
#include<iostream>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
  
    string s[2000];
    for (int i = 0; i < h; i++) {
      cin >> s[i];
    }
  
    int w_counter[2000];
    int h_counter[2000];
    for (int i = 0; i < h; i++) w_counter[i] = 0;
    for (int j = 0; j < w; j++) h_counter[j] = 0;
  
    int max_tmp, max = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (s[i][j] == '#') {
          w_counter[i] = 0;
          h_counter[j] = 0;
        } else {
          if (w_counter[i] == 0) {
            for (int k = 0; j+k < w && s[i][j+k] != '#'; k++) w_counter[i]++;
          }
          if (h_counter[j] == 0) {
            for (int k = 0; i+k < h && s[i+k][j] != '#'; k++) h_counter[j]++;
          }
        }
        max_tmp = w_counter[i] + h_counter[j] - 1;
        if (max < max_tmp) {
          max = max_tmp;
        }
      }
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(std::string C){
    cout << char(C[0] + 1) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b;
  cin >> a >> b;
  if(a == 1 || b == 1){
    if(a == b){
      cout << "Draw" << endl;
    } else if(a < b) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
  } else {
    if(a < b){
      cout << "Bob" << endl;
    } else if(b < a){
      cout << "Alice" << endl;
    } else {
      cout << "Draw" << endl;
    }
  }

  return 0;
}

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

string S;



int main(void){

    cin >> S;
    ll SL = S.length();

    if (S[SL-1] == 's') S += "es";
    else S += "s";

    cout << S << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
pair<int,int>h[1000000];
int add(char x,char y)
{
	return x==y;
}
int main()
{   string s;
	int n;
	cin>>n>>s;
	int len=s.length();
	for(int i=1; i<=len; i++)
	{
	  h[i]=make_pair(h[i-1].first+add(s[i-1],'W'),h[i-1].second+add(s[i-1],'E'));
	}
	int ans=1e9;
	for(int i=1; i<=len; i++)
	{
	  int t=h[i-1].first+
	  (h[len].second-h[i].second);
	  ans=min(ans,t);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4740
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
henka=[]
ans=[10**5+1]*3
ans=0
if m<=n:
    print(ans)
else:
    for i in range(m-1):
        sa=x[i+1]-x[i]
        henka.append(sa)
            
    henka.sort()
    for i in range(m-n):
        ans+=henka[i]
    print(ans)



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

using namespace std;

#define li long long int
#define ld long double
const int MX1 = 1e5 + 5;
const int MX2 = 1e6 + 5;
const li inf = 4e18;
const li mod = 1e9 + 7;

li power(li a, li b) { li res = 1; while (b) { if (b % 2) res = (res * a) % mod;
a = (a * a) % mod; b /= 2; } return res; }

li mmi(li a) { return power(a, mod - 2); }

li cntbit(li n) { li cnt = 0; while (n) { n &= (n - 1); cnt++; } return cnt; }

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		ans += x - 1;
	}
	cout << ans << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

# ab = []
# for i in a:
#     for j in b:
#         ab.append(i+j)
# ab.sort(reverse=True)

# ab = ab[:k]

# abc = []
# for i in ab:
#     for j in c:
#         abc.append(i+j)
# abc.sort(reverse=True)

# for i in range(k):
#     print(abc[i])

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

a_max = min(k, len(a))
b_max = min(k, len(b))
c_max = min(k, len(c))

abc = []
for i in range(1, k+1):
    if i > len(a):
        break
    for j in range(1, k//i+1):
        if j > len(b):
            break
        for l in range(1, k//(i*j)+1):
            if l > len(c):
                break
            # print(i, j, l)
            abc.append(a[i-1]+b[j-1]+c[l-1])

# print(abc)
# print(k)
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])


Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<int> dp(k+1, 0);
	REP(i, k) {
		REP(j, n) {
			if (i + a[j] < k + 1) {
				chmax(dp[i + a[j]], 1 - dp[i]);
			}
		}
	}
	if (dp[k] == 1) {
		put("First");
	} else {
		put("Second");
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int empty = A - B;
		int ret = C- empty;
		if(ret < 0){
			ret = 0;
		}
		System.out.println(ret);

		sc.close();
	}
}


Measured memory_bytes: 22868
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!{
        mut s:String
    }

    if s.chars().last().unwrap() == 's' {
        s.push('e');
    }
    s.push('s');
    println!("{}", s);
}


Measured memory_bytes: 2208
/*
*	author:		richardjcy
*	created:	2020/09/26/07:56.04
*/

#include <bits/stdc++.h>
using namespace std;

unordered_set<string> st = {"01","02","03","04","05","06","07","08","09","10","11","12"};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    bool ok1 = false, ok2 = false;
    if (st.find(s.substr(0, 2)) != st.end()) ok1 = true;
    if (st.find(s.substr(2)) != st.end()) ok2 = true;
    if (ok1 && ok2) cout << "AMBIGUOUS" << endl;
    else if (ok1) cout << "MMYY" << endl;
    else if (ok2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define maxn 200005
#define fto(i,j,h)   for (int i=j; i<=h; ++i)
#define fdto(i,j,h) for (int i=j; i>=h;  --i)
#define ll long long
#define pii pair<long long, long long>
#define fi first
#define se second
using namespace std;

int n, h[maxn];
ll C;
pii F[4*maxn];
void khoitao(int k, int l, int r){
    F[k].fi = 0;   F[k].se = 1e18;
    if (l == r){
        return ;
    }
    int mid = (l+r)/2;
    khoitao(k*2, l, mid);
    khoitao(k*2+1, mid+1, r);
}
ll Getnode(pii u, int x){
    return u.fi*h[x] + u.se;
}
void ud(int k, int L, int R, int l, int r, pii val){
    if (L > r || R < l)    return;
    int mid = (l+r)/2;
    if (L <= l && R >= r){
        if (Getnode(F[k], l) <= Getnode(val, l) && Getnode(F[k], r) <= Getnode(val, r)){
            return;
        }
        if (Getnode(F[k], l) >= Getnode(val, l) && Getnode(F[k], r) >= Getnode(val, r)){
            F[k] = val;
            return;
        }
        if (Getnode(F[k], l) <= Getnode(val, l) && Getnode(F[k], mid) <= Getnode(val, mid)){
            ud(k*2+1, L, R, mid+1, r, val);
            return;
        }
        if (Getnode(F[k], l) >= Getnode(val, l) && Getnode(F[k], mid) >= Getnode(val, mid)){
            ud(k*2+1, L, R, mid+1, r, F[k]);
            F[k] = val;
            return;
        }
        if (Getnode(F[k], mid+1) <= Getnode(val, mid+1) && Getnode(F[k], r) <= Getnode(val, r)){
            ud(k*2, L, R, l, mid, val);
            return;
        }
        if (Getnode(F[k], mid+1) >= Getnode(val, mid+1) && Getnode(F[k], r) >= Getnode(val, r)){
            ud(k*2, L, R, l, mid, F[k]);
            F[k] = val;
            return;
        }
        return;
    }
    ud(k*2, L, R, l, mid, val);
    ud(k*2+1, L, R, mid+1, r, val);
}
ll Get(int k, int id, int l, int r){
    if (id < l || id > r)   return 1e18;
    ll rs = Getnode(F[k], id);
    if (l == r)             return rs;
    int mid = (l+r)/2;
    rs = min(rs, Get(k*2, id, l, mid));
    rs = min(rs, Get(k*2+1, id, mid+1, r));
    return rs;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> C ;
    fto(i,1,n)    cin >> h[i];
    khoitao(1, 1, n);
    pii t;
    t.fi = -2*h[1];
    t.se = 1ll*h[1]*h[1];
    ud(1, 2, n, 1, n, t);
    fto(i,2,n){
       ll w = Get(1, i, 1, n) + 1ll*h[i]*h[i] + C;
       if (i == n)   {cout << w;  break;}
       pii t;
       t.fi = -2*h[i];
       t.se = w + 1ll*h[i]*h[i];
       ud(1, i+1, n, 1, n, t);
    }
}


Measured memory_bytes: 12668
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x[] = new int[n];
    int b=0;
    long answer =0; 
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt()-(i+1);
    }
    Arrays.sort(x);
    if(n%2==0){
      b=(x[n/2]+x[(n/2)-1])/2;//中央値
    }else{
      b=x[(n-1)/2];//中央値
    }
    for(int i=0;i<n;i++){
      answer =answer +Math.abs(x[i]-b);
    }
    System.out.println(answer);
    
      
  }
  

  
}

Measured memory_bytes: 65144
//#include<bits/stdc++.h>
//using namespace std;
//int main()
//{
//	return 0;
//}
/*
#include<bits/stdc++.h>
using namespace std;
int kk;
long long ans=0;
int main()
{
	scanf("%d",&kk);
	int i=1,j=1,k=1;
	while(i<=kk)
	{
		j=1;
		while(j<=kk)
		{
			k=1;
			while(k<=kk)
			{
				ans+=1ll*__gcd(__gcd(i,j),k);
				++k;
			}
			++j;
		}
		++i;
	}
	printf("%lld\n",ans);
	return 0;
}
*/
/*
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main()
{
	scanf("%lld",&n);
	ans=(1+n)*n/2;
	long long tmp=n/3ll;
	if(n>=3) ans-=(tmp*3ll+3ll)*tmp/2ll;
	tmp=n/5ll;
	if(n>=5) ans-=(tmp*5ll+5ll)*tmp/2ll;
	tmp=n/15ll;
	if(n>=15) ans+=(tmp*15ll+15ll)*tmp/2ll;
	printf("%lld\n",ans);
	return 0;
}
*/
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	int i=1,p=1;
	while(i<=5)
	{
		int tmp=n%(p*10);
		tmp/=p;
		if(tmp==7)
		{
			printf("Yes\n");
			return 0;
		}
		p*=10;
		++i;
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 3688
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> v;
  if (s[0] == '0') v.push_back(0);
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n && s[i] == s[j]) j++;
    if (j > i) {
      v.push_back(j - i);
      i = j - 1;
    }
  }
  vector<int> sum((int) v.size() + 1);
  for (int i = 0; i < (int) v.size(); i++) {
    sum[i + 1] = sum[i] + v[i];
  }
  int ans = 0;
  for (int i = 1; i < (int) sum.size(); i += 2) {
    ans = max(ans, sum[min((int) sum.size() - 1, i + 2 * k)] - sum[i - 1]);
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int A[3], ans=0;

	rep(i,3) cin >> A[i];

	while( A[0] != A[1] || A[1] != A[2] ){
		sort(A, A+3);
		ans++;
		if( A[1] == A[2] ) A[0] += 2;
		else{
			A[0] += 1;
			A[1] += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

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

    int N;
    cin >> N;

    if (N == 2) {
        cout << -1 << '\n';
        return 0;
    }

    if (N == 3) {
        cout << "aa." << '\n';
        cout << "..b" << '\n';
        cout << "..b" << '\n';
        return 0;
    }

    vector<string> solutions[8];

    solutions[4] = {"aacd", "bbcd", "ghee", "ghff"};
    solutions[5] = {"aabbc", "hii.c", "h..jd", "g..jd", "gffee"};
    solutions[6] = {"aa.ccd", "..bf.d", "..bfee", "ccdaa.", "f.d..b", "fee..b"};
    solutions[7] = {"aabbcc.", "gg.gg.d", "..h..hd", "..h..he", "gg.gg.e", "..h..hf", "..h..hf"};

    vector<string> answer(N, string(N, '.'));
    int end = N;

    while (end >= 8) {
        for (int row = 0; row < 4; row++)
            for (int col = 0; col < 4; col++)
                answer[end - 4 + row][end - 4 + col] = solutions[4][row][col];

        end -= 4;
    }

    for (int row = 0; row < end; row++)
        for (int col = 0; col < end; col++)
            answer[row][col] = solutions[end][row][col];

    for (int i = 0; i < N; i++)
        cout << answer[i] << '\n';
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
using namespace std;
#define F(I,J,N) for(int I=J;I<N;I++)

void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(){
	int *l;
	int p,q;
	int x,y;
	while(cin>>p){
		l=new int[p];
		F(i,0,p) l[i]=i+1;
		cin>>q;
		F(i,0,q){
			scanf("%d,%d",&x,&y);
			swap(&l[x-1],&l[y-1]);
		}
		F(i,0,p) cout<<l[i]<<endl;
		delete []l;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string y,m,d;
  m = s.substr(5,2);
  if(m == "04"|| m == "03" ||m == "02"||m == "01"){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

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

int main() {
	int n,q;
	cin>>n>>q;
	
	string str;
	cin>>str;
	
	int arr[n];
	arr[0] = 0;
	
	for(int i=1; i<n; i++){
	    arr[i] = arr[i-1];
	    if(str[i-1]=='A' && str[i] == 'C'){
	        ++arr[i];
	    }
	}
	int l,r;
	
	while(q--){
	    cin>>l>>r;
	    l--;r--;
	    
	    cout<<arr[r]-arr[l]<<'\n';
	}
}

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

int main(){
int k;
string s;
cin >> k;
cin >> s;
vector<string> o;

if(k >= s.size())
cout << s << endl;
else {
for(int i=0;i < k;++i)
cout << s.at(i);
cout << "..." << endl;

}


}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k, a);
    k = max(0LL, k - a);
    k = max(0LL, k - b);
    ans -= min(k, c);
    print(ans);
}

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

using namespace std;
typedef long long ll;

ll N;
ll F[11][11];

int main(){
    cin >> N;
    ll c = 0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            F[i][j] = 0;
        }
    }
    for(int i=1;i<=N;i++){
        string s = to_string(i);
        if(s[s.size()-1] == '0') continue;
        F[s[0]-'0'][s[s.size()-1]-'0']++;
    }
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            c += F[i][j] * F[j][i];
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    int arr[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            arr[i][j] =0;
    }
    int count[n]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            arr[i][j] = min(j-i,abs(x-1-i) + 1 + abs(y-1-j));
            count[arr[i][j]]++;
        }
    }
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cout<<arr[i][j]<<" ";
        cout<<endl;
    }*/
    for(int i=1;i<n;i++)
        cout<<count[i]<<endl;
}


Measured memory_bytes: 15872
import sys
input = sys.stdin.readline
from collections import Counter
from fractions import Fraction
from math import gcd

N=int(input())
mod=10**9+7

S=[tuple(map(int,input().split())) for i in range(N)]

def main():
    C=Counter()
    PLUS=0
    for a,b in S:
        if a==0 and b==0:
            PLUS+=1
        elif a==0:
            C[(0,1)]+=1
        elif b!=0 and a>0:
            C[(a//gcd(a,b),b//gcd(a,b))]+=1
        elif b!=0 and a<0:
            C[(-a//gcd(a,b),-b//gcd(a,b))]+=1
            
        else:
            C[float("inf")]+=1
        
    ANS=1

    #print(C)

    for x in list(C.keys()):
        if x!=float("inf") and x!=(0,1):

            a,b=x

            if b>0:
                ANS=ANS*(pow(2,C[x],mod)+pow(2,C[(b,-a)],mod)-1)%mod
                C[(b,-a)]=0
            else:
                ANS=ANS*(pow(2,C[x],mod)+pow(2,C[(-b,a)],mod)-1)%mod
                C[(-b,a)]=0
                
            C[x]=0

            
        else:
            ANS=ANS*(pow(2,C[float("inf")],mod)+pow(2,C[(0,1)],mod)-1)%mod

            C[float("inf")]=0
            C[(0,1)]=0

    print((ANS-1+PLUS)%mod)

main()
    


Measured memory_bytes: 109032
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int dp[N], n, k;
vector<int> v(N);
int res(int id)
{
		if(id == n -1)
    	return 0;
    int &ans = dp[id];
    if(ans != -1)
    	return ans;
    ans = 1e9;
    for(int i = 1; i  <= k; i++){
    	if(id + i >= n)
             break;
        ans = min(ans, abs(v[id + i] - v[id]) + res(id + i));
    }
     return ans;
}

int32_t main() 
{
		
    cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
    	cin>>v[i];
    }
    cout<<res(0);
}

Measured memory_bytes: 9480
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int p[5000];
    for(int i=0; i<N; i++)
    {
        cin>>p[i];
    }
    int min_sum =20000;
    for(int I=0;I<=p[0];I++)
    {
        int q[5000];
        for(int i=0;i<N;i++)
        {
            q[i] = p[i];
        }
        int sum = I;
        q[0]-= I;
        for(int i=0;i<=N-2;i++)
        {
            if(q[i]<=0)
            continue;

            sum += q[i]*2;
            q[i+1]-=q[i];
        }
        if(q[N-1]>0)
        {
            sum +=q[N-1];
        }
        min_sum = min(min_sum,sum);
    }
    cout<<min_sum<<endl;
    return 0;



}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int s, w;
	cin >> s >> w;
	if (s > w)cout << "safe";
	else cout << "unsafe";
	return 0;
}

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

#define ul unsigned long long
#define ll long long

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

  string agct = "ACGT";
  ul ct=0,cml=0;
  for (size_t i = 0; i < s.length(); i++)
  {
    if (agct.find(s[i])!=string::npos) cml++;
    else {
      ct=max(ct,cml);
      cml=0;
    }
  }
  ct = max(ct, cml);
  cout << ct << endl;

  return 0;
}




Measured memory_bytes: 256