akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

std::int64_t run(std::int64_t N)
{
	std::int64_t sum = 0;
	for (std::int64_t x = 1; x * (x + 1) < N; ++x)
	{
		if (N % x == 0)
		{
			sum += N / x - 1;
		}
	}
	return sum;
}

void Main()
{
	std::int64_t N;
	std::cin >> N;
	std::cout << run(N) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[101];
		int max = 0;
		while(sc.hasNext()) {
			int a = sc.nextInt();
			c[a]++;
			if(max < c[a]) {
				max = c[a];
			}
		}
		sc.close();
		for(int i = 1; i < 101; i++) {
			if(max == c[i]) {
				System.out.println(i);
			}
		}
	}
}



Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,a,li[100010];

int main(){
	cin >> n >> li[0];
	
	int l=1;
	REP(i,1,n){
		cin >> a;
		if(li[l-1]<a) li[l++]=a;
		else *lower_bound(li,li+l,a)=a;
	}
	
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>

using namespace std;

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

    string s[n];
    long long int ans = 0;

    map<string, long long int> mp;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    for (int i = 0; i < n; i++) {
        mp[s[i]]++;
    }

    for (auto x: mp) {
        if (x.second == 1) continue;

        for (int i = 1; i < x.second; i++) {
            ans += i;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 18176
import sys
sys.setrecursionlimit(1000000)
n, x = map(int, input().split())
layers = [1]
pats = [1]
cnt = 1
p_cnt = 1
for _ in range(n):
  cnt = cnt * 2 + 3
  p_cnt = p_cnt * 2 + 1
  layers.append(cnt)
  pats.append(p_cnt)
def solve(lev, rest):
  if rest == 0:
    return 0
  if lev == 0:
    return 1
  if rest - 1 <= layers[lev - 1]:
    return solve(lev - 1, rest - 1)
  elif rest - 1 == layers[lev - 1]:
    return pats[lev - 1] + 1
  else:
    return pats[lev - 1] + 1 + solve(lev - 1, rest - 1 - layers[lev - 1] - 1)

print(solve(n, x))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using namespace std;

using ll = long long;

template<class T>
struct Kruskal{

  struct edge{
    int from,to;
    T cost;
    int used;
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };
  vector<int> r,p;
  vector<edge> es;

  Kruskal(){}
  Kruskal(int n):r(n,1),p(n){
    iota(p.begin(),p.end(),0);
  }

  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

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

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
  }

  T build(){
    sort(es.begin(),es.end());
    T res=0;
    for(auto &e:es){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

using P = std::pair<ll, int>;

int N;
std::vector<P> xs, ys;

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

  rep( i, N )
  {
    ll x, y;
    scanf( "%lld%lld", &x, &y );

    xs.emplace_back( P( x, i ) );
    ys.emplace_back( P( y, i ) );
  }

  std::sort( all(xs) );
  std::sort( all(ys) );

  Kruskal<ll> ks( N );

  rep( i, N-1 )
  {
    ks.add_edge( xs[i].second, xs[i+1].second, xs[i+1].first-xs[i].first );
    ks.add_edge( ys[i].second, ys[i+1].second, ys[i+1].first-ys[i].first );
  }

  printf( "%lld\n", ks.build() );

  return 0;
}

Measured memory_bytes: 13792
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int resaleGain = 0;
    sc.nextLine();
    String[] values = sc.nextLine().split(" ");
    String[] costs = sc.nextLine().split(" ");
    for (int i = 0; i < n; i++) {
      int v = Integer.parseInt(values[i]);
      int c = Integer.parseInt(costs[i]);
      if (v - c > 0) {
        resaleGain += v - c;
      }
    }
    pw.println(resaleGain);
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;
	vector<string> w;
	set<string> s;

	cin >> n;

	w.resize(n);

	REP(i, n) {
		cin >> w[i];
		s.insert(w[i]);
	}

	if (s.size() != w.size()) {
		cout << "No" NL;
		return 0;
	}


	FOR(i, 1, n) {
		if (w[i - 1].back() != w[i].front()) {
			cout << "No" NL;
			return 0;
		}

	}

	cout << "Yes" NL;


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")

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

const int N = 1e6+1;
vector<int> spf(N+5, -1);

unordered_map<int,int> get_factors(int x){
	unordered_map<int,int> mp;
	while(x>1){
		mp[spf[x]]++;
		x /= spf[x];
	}
	return mp;
}

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

	for(int i=2;i<N;i++){
		if(spf[i] != -1) continue;
		for(int j=i;j<N;j+=i){
			if(spf[j]==-1) spf[j] = i;
		}
	}

	long long ans = 0;
	while(--n){
		unordered_map<int,int> f = get_factors(n);
		long long temp = 1;
		for(auto x : f){
			temp *= (1+x.second);
		}
		ans += temp;
	}	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7036
import fractions
a,b,k=map(int,input().split())

gcd=fractions.gcd(a,b)
div=[]
for i in range(1, int(gcd**0.5)+1):
  if gcd%i==0:
    div.append(i)
    if i!= gcd//i:
      div.append(gcd//i)
print(sorted(div,reverse=True)[k-1])

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

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

  rep(i,s.length()){
    rep(j,s.length()-i-1){
      if(s[i]==s[s.length()-j-1]){
	cout << "no" << endl;
	return 0;
      }
    }
  }

  cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int H){
	int table[H][5];

	for(int i = 0; i < H; i++){
		for(int k = 0; k < 5; k++)scanf("%d",&table[i][k]);
	}

	bool FLG;
	int count = 0;

	while(true){

		FLG = false;

		for(int i = 0; i < H; i++){
			for(int k = 0,p = 0; k <= 2; k++){
				if(table[i][k] == -1)continue;
				for(p = 1; k+p < 5 && table[i][k+p] == table[i][k]; p++);
				if(p >= 3){
					for(int a = k; a < k+p; a++){
						count += table[i][a];
						table[i][a] = -1;
						FLG = true;
					}
					break;
				}
			}
		}

		for(int col = 0; col < 5; col++){
			for(int row = H-2,i = 0; row >= 0; row--){
				if(table[row][col] != -1){
					for(i = row+1; i < H && table[i][col] == -1; i++);
					if(i > row+1){
						table[i-1][col] = table[row][col];
						table[row][col] = -1;
					}
				}
			}
		}

		if(!FLG)break;
	}

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


int main(){

	int H;

	while(true){
		scanf("%d",&H);
		if(H == 0)break;

		func(H);
	}

    return 0;
}

Measured memory_bytes: 2716
#include<iostream>
//#include<fstream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<stdlib.h>
using namespace std;
//ifstream cin("d.in");
//ofstream cout("d.out");
int main()
{
	char a[110];
	int sum=0;
	cin>>a;
	for(int i=1;i<strlen(a)-1;i++)
	{
		if(a[i]<='z'&&a[i]>='a')
		{
			sum++;
		}
	}
	cout<<a[0]<<sum<<a[strlen(a)-1];
	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
PS = [list(input().split()) for x in range(M)]

question = [0]*(N+1)
wrong = [0]*(N+1)

for i in range(M):
    if PS[i][1] == 'AC':
        if question[int(PS[i][0])] == 0:
            question[int(PS[i][0])] = 1
    else:
        if question[int(PS[i][0])] == 0:
            wrong[int(PS[i][0])] += 1

WA = 0
for i in range(N+1):
    if question[i] == 1:
        WA += wrong[i]

print(sum(question), WA)

Measured memory_bytes: 27460
#include<iostream>

using namespace std;

int A[1005][1005];

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

    int n,m,a,b;
    cin>>n>>m>>a>>b;

    //vals on the lines
    for(int i=1; i<=n; i++)
        for(int j=1; j<=a; j++)
            A[i][j]=1;

    //now all the results on the columns are 0 so we can solve like w/o influencing the results on lines
    for(int i=1; i<=b; i++)
        for(int j=1; j<=m; j++)
            A[i][j]^=1;

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
            cout<<A[i][j];
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5120
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[M];
        int sum = 0;

        for(int i=0; i<M; i++){
            A[i] = sc.nextInt();
            sum += A[i];
        }
        if(sum<=N){
            System.out.println(N - sum);
        }
        else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 46504
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    ll b[200005];
    ll dp[200005];
    vector<pair<ll,ll> >v;
    int main()
    {
        fastread;
        ll H,n,i,j,k,l,m;
        cin>>H>>n;
        for(i=1;i<=H;i++)
        dp[i]=1e9;
        for(i=1;i<=n;i++){
        	cin>>k>>l;
        	v.pb({k,l});
		}
		for(i=0;i<n;i++){
			for(j=1;j<=H;j++){
				if(j-v[i].fi<=0){
					dp[j]=min(dp[j],v[i].se);
				}
				else{
						dp[j]=min(dp[j],v[i].se+dp[j-v[i].fi]);
				}
			}
		}
		//for(i=1;i<=H;i++)
		cout<<dp[H]<<" ";
    	return 0;
    }

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static final long MOD = 1_000_000_000 + 7;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length();
		
		long sum = 0;
		for (int i = 0; i < 1 << (len - 1); i++) {
			int n = i;
			int l = 0;
			
			for (int j = 1; j < len; j++) {
				if ((n & 1) == 1) {
					sum += Long.valueOf(s.substring(l, j));
					l = j;
				}
				n /= 2;
			}
			sum += Long.valueOf(s.substring(l));
		}
		
		System.out.println(sum);
		
		sc.close();
	}
}




Measured memory_bytes: 27468
#include <iostream>
#include<math.h>
using namespace std;

bool isPrime(int n){
	int sq = sqrt((double)n);
	if (n == 1)return false;
	if (n == 2)return true;
	for (int i = 2; i <= sq; ++i)
	if (n%i == 0)return false;
	return true;
}

int main(){
	int N, z, c, i;
	for (cin >> N, c = 0; cin >> z, isPrime(z) ? ++c : 0, --N;);
	cout << c << endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner scan=new Scanner(System.in);
    	String a=scan.next();
    	int ans=0;
    	for(int i=0;i!=6;i++) {
    	if(a.charAt(i)=='1') {
    		ans++;
    	}
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 22100
n = int(input())
s = [input() for i in range(n)]
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

# [[1, 1], [0, 1], [0, 0], [1, 0]]
dic = {}

for i in range(n):
    sen = '・'.join(sorted(s[i]))
    #print(sen)
    if sen not in dic:
        dic[sen]=1
    else:
        dic[sen]+=1    
#print(dic)
ans = 0
for i in dic.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 29204
#include<stdio.h>
int main(){
  int N;
  int H[21];
  int i,j,cnt=0,min=0;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&H[i]);
  }
  H[0]=0;
  for(i=1;i<=N;i++){
    for(j=0;j<i;j++){
      if(H[j]>H[i]){
        min=1;
      }
    }
    if(min==0){
      cnt++;
    }else if(min==1){
      min=0;
    }
  }
  printf("%d\n",cnt);


  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;
set<int> st;

signed main() {
	cin >> a >> b;
	int x = gcd(a, b);
	for (int i = 2; i <= sqrt(x); i++) {
		while (!(x%i)) {
			x /= i;
			st.insert(i);
		}
	}
	if (1 < x)st.insert(x);
	cout << (int)st.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e7;
#define zon 3e9 + 3e8
int k;
vector <LL> ans;
LL res[(int)maxx];
int l = 1, r = 0;

void Solve() {
	for(int i = 1; i < 10; i++) res[++r] = i;
	while(r > l) {
		LL now = res[l++];
		if(now > 1e11) return ;
		ans.push_back(now);
		int mod = now % 10;
		res[++r] = 10LL * now + mod;
		if(mod != 0) res[++r] = 10LL * now + mod - 1;
		if(mod != 9) res[++r] = 10LL * now + mod + 1;
	}
}

int main() {
	Solve();
	cin >> k;
	sort(ans.begin(), ans.end());
	cout << ans[k - 1] << endl;
	return 0;
}

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

#define MAXN 100010
#define ll long long

using namespace std;

string s;

int main() {
	cin >> s;
	if (s == "SAT") cout << 1 << endl;
	else if (s == "SUN") cout << 7 << endl;
	else if (s == "MON") cout << 6 << endl;
	else if (s == "TUE") cout << 5 << endl;
	else if (s == "WED") cout << 4 << endl;
	else if (s == "THU") cout << 3 << endl;
	else if (s == "FRI") cout << 2 << endl;
	return 0;
}

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

#define MAXN 1001
#define MOD 1000000007

using namespace std;

long long dp[MAXN][MAXN];

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

    int h, w;
    string line;
    cin >> h >> w;

    dp[0][1] = 1;
    for(int i = 1; i <= h; ++i){
        cin >> line;
        for(int j = 0; j < w; ++j)
            if(line[j] != '#')
                dp[i][j + 1] = (dp[i - 1][j + 1] + dp[i][j]) % MOD;
    }


    cout << dp[h][w] << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 8064
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int n;
  cin >> n;
  vi32 b(n + 1, 1e9);
  rep(i, n - 1) cin >> b[i + 1];
  vi32 a(n);
  int p = 1e9;
  rep(i, n) {
    a[i] = min(b[i], b[i + 1]);
  }
  int ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#coding:utf-8
#1_5_C 2015.4.1
while True:
    length,width = map(int,input().split())
    if length == width == 0:
        break

    for i in range(length):
        for j in range(width):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

            if j == width - 1:
                print()
    print()

Measured memory_bytes: 6804
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	string s;
	cin>>s;
	int n = s.length();
	if(s[n-1] == 's') cout<<s<<"es"<<en;
	else cout<<s<<"s"<<en;
}

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


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

struct Point{
    ll x, y;
    Point(ll _x, ll _y){
        x = _x;
        y = _y;
    }
};

ll dist(Point a, Point b){
    ll ans = abs(a.x - b.x) + abs(a.y - b.y);
    return ans;
}

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

    // input
    ll H, W;
    cin >> H >> W;

    vector<Point> V;
    FOR(i, 0, H){
        string s; cin >> s;
        FOR(j, 0, W){
            if(s[j]=='B'){
                V.push_back(Point(j, i));
            }
        }
    }

    ll L = V.size();
    ll ma = 0;
    FOR(i, 0, L){
        FOR(j, i+1, L){
            ll d = dist(V[i], V[j]);
            chmax(ma, d);
        }
    }
    p(ma);
    
    return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  =long long;
int main()
{
    ll x;
    cin>>x;
  ll n500 = x/500;
  ll points = 1000*n500;
  x=x-500*(n500);
  ll n5=x/5;
  points+=5*n5;
  cout<<points;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
                    #include <vector>
                    #include <bits/stdc++.h>
                    using namespace std;
                    using Graph = vector<vector<int>>;
                    
                    //入力頂点番号を１マイナスしてずらしているので注意!!
                    //枝の数がM=N-1で以下では木になっているが変更可能
                    
                    // 深さ優先探索
                    vector<bool> seen;
                    void dfs(const Graph &G, int v, vector<int> &V, int b , map<pair<int,int>,int> &weight ) {
                        V.at(v)=b; 
                        seen[v] = true; // v を訪問済にする
                        //cout<< v <<endl;
                    
                        // v から行ける各頂点 next_v について
                        for (auto next_v : G[v]) { 
                            if (seen[next_v]) continue; // next_v が探索済だったらスルー
                            if ( (weight[make_pair( v, next_v )])%2 ==0 ) dfs(G, next_v, V , b, weight);
                            if ( (weight[make_pair( v, next_v )])%2 ==1 ) dfs(G, next_v, V , 1-b, weight); // 再帰的に探索
                        }
                    }
                    
                    int main() {
                        
                        //
                        map<pair<int,int>,int> weight;
                        
                        // 頂点数と辺数
                        int N, M; cin >> N;
                        M= N-1; 

                        // グラフ入力受取 (ここでは無向グラフを想定)
                        Graph G(N);
                        for (int i = 0; i < M; ++i) {
                            int a, b, w ;
                            cin >> a >> b >> w ;
                            G[a-1].push_back( b-1 );
                            G[b-1].push_back( a-1 );
                            
                            weight[make_pair(a-1,b-1)] = w; 
                            weight[make_pair(b-1,a-1)] = w; 
                        }
                        
                        vector<int> V(N,0);
                    
                        // 頂点 0 をスタートとした探索
                        seen.assign(N, false); // 全頂点を「未訪問」に初期化
                        dfs(G, 0, V, 0, weight);
                        
                        for(int i=0; i<N; i++){
                            cout<< V.at(i) << endl;
                        }
                    }


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, m;
    int s, c;
    
    cin >> n >> m;
    
    char ans[9];
    
    for(int i=1; i<=n; i++){
        
        ans[i] = 'e';
        
    }
    
    if(m==0){
        
        if(n==1){
            
            cout << "0" << endl;
            return 0;
            
        } else if(n==2){
            
            cout << "10" << endl;
            return 0;
            
        } else {
            
            cout << "100" << endl;
            return 0;
            
        }
        
    }
    
    for(int i=1; i<=m; i++){
        
        cin >> s >> c;
        
        if(ans[s]!='e'&&ans[s]!=c+'0'){
            
            cout << "-1" << endl;
            return 0;
            
        } else {
            
            ans[s] = c + '0';
            
        }
        
    }
    
    for(int i=1; i<=n; i++){
        
        if(ans[i]=='e'){
            
            if(n>=2&&i==1){
                
                ans[i] = '1';
                
            } else {
                
                ans[i] = '0';
                
            }
            
        }
        
    }
    
    if(n>=2&&ans[1]=='0'){
        
        cout << "-1" << endl;
        return 0;
        
    }
    
    for(int i=1; i<=n; i++){
        
        cout << ans[i];
        
    }
    
    cout << endl;
    
    return 0;
    
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, M;
    int R;
    int Q;
    while(true){
        cin >> N >> M;
        if(N == 0) break;
        cin >> R;
        vector<int> tm(R);
        vector<int> no(R);
        vector<int> sid(R);
        vector<int> sw(R);
        rep(i, R) cin >> tm[i] >> no[i] >> sid[i] >> sw[i];
        cin >> Q;
        rep(i, Q){
            int ans = 0;
            int start, fin, m; cin >> start >> fin >> m;
            int record = 0;
            set<int> in_use;
            for(int j = tm[record]; j < fin; j++){
                if(record < R){
                    if(j == tm[record]){
                        if(sid[record] == m){
                            if(sw[record]){
                                in_use.insert(no[record]);
                            }
                            else in_use.erase(no[record]);
                        }
                        j--;
                        record++;
                        continue;
                    }
                }
                if(in_use.size() > 0){
                    if(start <= j) ans++;
                } 
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int state[310];

struct mac{
	int a,b,c;
};

int main(void){
	while(1){
		vector<mac> suc;
		vector<mac> mis;
		int a,b,c;
		cin >> a >> b >> c;
		int n=a+b+c;
		if(n==0)
			break;
		rep(i,n) state[i]=2;
		int m;
		cin >> m;
		rep(i,m){
			int d;
			cin >> a >> b >> c >> d;
			mac tmp; tmp.a=a-1; tmp.b=b-1; tmp.c=c-1;
			if(d){
				suc.pb(tmp);
			}else{
				mis.pb(tmp);
			}
		}
		rep(i,suc.size()){
			state[suc[i].a]=1;
			state[suc[i].b]=1;
			state[suc[i].c]=1;
		}
		rep(i,mis.size()){
			if(state[mis[i].a]==1&&state[mis[i].b]==1)
				state[mis[i].c]=0;
			
			if(state[mis[i].b]==1&&state[mis[i].c]==1)
				state[mis[i].a]=0;
			
			if(state[mis[i].c]==1&&state[mis[i].a]==1)
				state[mis[i].b]=0;
		}
		rep(i,n)
			cout << state[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N;
	cin >> N;
	vector<pair<pair<string, int> , int>> vec(N);
	for(int i = 0; i < N; i++){
		string s;
		int p;
		cin >> s >> p;
		vec[i] = make_pair(make_pair(s, -p), i+1);
	}

	sort(vec.begin(), vec.end());

	for(int i = 0; i < N; i++){
		cout << vec[i].second << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 998244353;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;




int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll n;
	cin>>n;
	ll p[n+1] , pos[n+1];
	for(ll i = 1; i<=n ; i++)
		{
			cin>>p[i];
			pos[p[i]] = i;
		}
	ll rfm[n+1], rsm[n+1], lfm[n+1], lsm[n+1];
	set <ll> pset;
	for(ll i = n ; i>=1 ; i--)
	{
		ll cpos = pos[i];
		auto itr = pset.lower_bound(pos[i]);
		if(itr == pset.end())
		{
			rfm[i] = n+1;
			rsm[i] = n+1;
		}
		else
		{
			rfm[i] = *itr;
			itr++;
			if( itr == pset.end() )
				{
					rsm[i] = n+1;
				}
			else
				{
					rsm[i] = *itr;

				}
		}
		pset.insert(pos[i]);
	}
	pset.clear();
	for(ll i = n ; i>=1 ; i--)
	{
		ll cpos = pos[i];
		auto itr = pset.lower_bound(-pos[i]);
		if(itr == pset.end())
		{
			lfm[i] = 0;
			lsm[i] = 0;
		}
		else
		{
			lfm[i] = -(*itr);
			itr++;
			if(itr == pset.end())
			{
				lsm[i] = 0;
			}	
			else
			{
				lsm[i] = -(*itr);
			}
		}
		pset.insert(-pos[i]);
	}
	// for(ll i = 1; i<=3 ; i++)
	// {
	// 	cout<<"rfm : "<<rfm[i];
	// 	cout<<"		rsm : "<<rsm[i];
	// 	cout<<"		lfm : "<<lfm[i];
	// 	cout<<"		lsm : "<<lsm[i];
	// 	cout<<endl;

	// }

	ll sum = 0;
	for(ll i = 1; i<=n ; i++)
	{
		sum += i * (pos[i] - lfm[i]) * (rsm[i] - rfm[i]);
		sum += i * (rfm[i]-pos[i]) * (lfm[i] - lsm[i]);
	}

	cout<<sum<<endl;

	return 0;
	
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> C(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>C[i][j];
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if(C[i][j]-C[i][j+1]!=C[i+1][j]-C[i+1][j+1] || C[i][j]-C[i+1][j]!=C[i][j+1]-C[i+1][j+1]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    vector<int> t(110000),x(110000),y(110000);
    cin>>N;
    t.at(0)=x.at(0)=y.at(0)=0;
    for(int i=0;i<N;i++)cin>>t.at(i+1)>>x.at(i+1)>>y.at(i+1);
    bool can=true;
    for(int i=0;i<N;i++){
        int dt=t.at(i+1)-t.at(i);
        int dist=abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i));
        if(dt<dist)can=false;
        if(dist%2!=dt%2)can=false;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void){
    int sum = 700;
    char s[3];
    for(int i = 0;i < 3;i++){
     cin >> s[i];
    if(s[i] == 'o'){
        sum += 100;
    }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define len(x) x.size()
#define all(x) x.begin(), x.end()

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N, M, X;
	cin >> N >> M >> X;
	int cost[N];
	int learn[N][M];
	for (int i = 0; i < N; i++) {
		cin >> cost[i];
		for (int j = 0; j < M; j++) {
			cin >> learn[i][j];
		}
	}

	int best = INT_MAX;
	for (int i = 0; i < 1<<N; i++) {
		int skill[M];
		int c = 0;
		memset(skill, 0, M*4);
		for (int j = 0; j < N; j++) {
			if ((1<<j)&i) {
				c += cost[j];
				for (int k = 0; k < M; k++) {
					skill[k] += learn[j][k];
				}
			}
		}
		bool good = true;
		for (int j = 0; j < M; j++) {
			if (skill[j] < X) good = false;
		}
		if (good) {
			best = min(best, c);
		}
	}

	if (best == INT_MAX) cout << -1 << endl;
	else cout << best << endl;

}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

int main()
{
    IOS

    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    	cin>>a[i];
    ll dp[k+1][n],dp1[k+1][n];
    memset(dp,0,sizeof(dp));
    memset(dp1,0,sizeof(dp1));
    for(ll i=0;i<n;i++)
    	{dp[0][i]=1;dp1[0][i]=1;}
    for(ll i=1;i<=k;i++)
    {
    	for(ll j=0;j<n;j++)
    	{
    		if(j==0)
    		{
    			dp[i][j]=i<=a[j]?1:0;
    			dp1[i][j]=dp1[i-1][j]+dp[i][j];
    			dp1[i][j]%=mod;
    		}
    		else
    		{

    			dp[i][j]=a[j]<i?dp1[i][j-1]-dp1[i-a[j]-1][j-1]+mod:dp1[i][j-1];
    			dp[i][j]%=mod;

    			dp1[i][j]=dp1[i-1][j]+dp[i][j];
    			dp1[i][j]%=mod;
    			/*for(ll m=0;m<=min(a[j],i);m++)
    				dp[i][j]+=dp[i-m][j-1];*/
    		}
    		//cout<<dp1[i][j]<<" ";

    	}
    	/*cout<<endl;
    	for(ll j=0;j<n;j++)
    		cout<<dp[i][j]<<" ";

    	cout<<endl;*/
    }



    cout<<dp[k][n-1]<<endl;






    
}
    
 
    
    


Measured memory_bytes: 156544
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n, x, t);
    ll time = 0;
    while (n > 0) {
        n -= x;
        time += t;
    }
    cout << time << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  string snum = to_string(n);
  bool ans = false;
  // for (size_t i = 0; i < snum.size(); i++) {
  //   int cnt = count(snum.begin(), snum.end(), snum[i]);
  //   if (cnt >= 3) ans = true;
  // }
  for (size_t i = 0; i < snum.size(); i++) {
    int cnt = 0;
    for (size_t j = 0; j < snum.size(); j++) {
      if (snum[j] == snum[i]) {
        cnt++;
        if (cnt >= 3) ans = true;
      }
      else cnt = 0;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int mod = 1e9 + 7;
Int INF = 1e18;

int main() {
    Int n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<char, Int>> v;
    char a = s[0];
    Int i = 0;
    Int cnt = 0;
    while (i < n) {
        a = s[i];
        cnt = 0;
        while (i < n && s[i] == a) {
            i++;
            cnt++;
        }
        v.emplace_back(a, cnt);
    }
    dump(v.size());
    return 0;
}

Measured memory_bytes: 2548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int n = Integer.parseInt(reader.readLine());
		for (int j = 0; j < n; j++) {
			StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
			boolean flag = true;
			int b = 0;
			int c = 0;
			for (int i = 0; i < 10; i++) {
				int a = Integer.parseInt(tokenizer.nextToken());
				if (a > b) {
					b = a;
				} else if (a > c) {
					c = a;
				} else {
					flag = false;
					break;
				}

			}
			System.out.println(flag ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 17016
# -*- coding: utf-8 -*-
#B
import sys
#import math


n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

#print(hoge)

for i in range(0,n-1):
	if(hoge[i]<hoge[i+1]):
		if(i==n-2):
			print("YES")
			sys.exit()
	else:
		break

for i in range(0,n-1):
	for j in range(i+1,n):
		k=hoge[j]
		hoge[j]=hoge[i]
		hoge[i]=k
		for m in range(0,n-1):
			if(hoge[m]<hoge[m+1]):
				if(m==n-2):
					print("YES")
					sys.exit()
			else:
				break
		k=hoge[j]
		hoge[j]=hoge[i]
		hoge[i]=k

print("NO")

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    long long sum = 0, minb = (long long)1e9 + 1, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        sum += a[i];
        if(a[i] > b[i]) minb = min(minb, b[i]);
    }
    if(a == b){
        cout << 0 << endl;
        return 0; 
    }
    ans = sum - minb;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a=0,n,t=0;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	sort(all(vec));
	while (a+1 < n && vec[a] + vec[a + 1] < 0) {
		vec[a] *= -1;
		vec[a + 1] *= -1;
		a += 2;
	}
	rep(i, n) {
		t += vec[i];
	}
	cout << t << endl;
}

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

char s[4];

int main(){
    for(int i = 0;i < 4;i++) cin >> s[i];
    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索する過程で親を更新
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]
n, m = map(int,input().split())
u = UnionFind(n)
ans = 0
for i in range(m):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1

    u.union(x,y)

for i in range(n):
    if u.par[i] == i:
        ans += 1

print(ans)

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool flg = true;
    for(int i = a;i <= b;i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            flg = false;
            break;
        }
    }
    if(flg) cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, m = 0, b = 0, c = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] >= m) m = a[i], c = i;
    }
    for (int i = 1; i <= n; i++) if (i != c && min(a[i], m - a[i]) >= min(b, m - b)) b = a[i];
    cout << m << ' ' << b;
}


Measured memory_bytes: 1024
from collections import Counter

S = [list(input()) for _ in range(int(input()))]
S_ = [Counter(s) for s in S]
S__ = [set(s.keys()) for s in S_]

res = S__[0]
for s in S__:
    res = res.intersection(s)

ans = {s: 0 for s in res}
for s in res:
    ans_ = min(s_[s] for s_ in S_)
    ans[s] = ans_

anss = list()
for s, v in ans.items():
    anss.append(s*v)

print(''.join(sorted(anss)))


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
char s[15];
int a[15]={0,1,2,3,4,5,6,7,8,9};
long long ans;
void recur (int a[], int data[], int start, int end, int index, int r) {
    if (index == r) {
        int last=0;
        for (int i=0;i<r;i++) {
            long long sum=0, temp=1;
            for (int j=data[i];j>=last;j--) {
                sum+=temp*(s[j]-'0');
                temp*=10;
            }
            ans+=sum;
            last=data[i]+1;
        }
        long long sum=0, temp=1;
        for (int j=strlen(s)-1;j>=last;j--) {
            sum+=temp*(s[j]-'0');
            temp*=10;        
        }
        ans+=sum;
        return;
    }
    for (int i=start; i<=end && end-i+1 >= r-index; i++) {
        data[index] = a[i];
        recur(a, data, i+1, end, index+1, r);
    }
}
void check (int a[], int n, int r) {
    int data[r];
    recur(a, data, 0, n-1, 0, r);
}
int main() {
    scanf("%s",s);
    for (int i=0;i<=strlen(s);i++) check(a,strlen(s)-1,i);
    printf("%lld\n",ans);
    return 0;
}

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

string s;
bool ans = false;

vector<string> str_set = {
    "dream",
    "dreamer",
    "erase",
    "eraser"};

void dfs(int i)
{
    if (i == s.size())
    {
        ans = true;
        return;
    }

    bool ok;

    rep(k, 0, str_set.size())
    if (i + str_set[k].size() - 1 <= s.size() - 1)
    {
        ok = true;
        rep(j, 0, str_set[k].size())
            ok &= str_set[k][j] == s[i + j];
        if (ok) dfs(i + str_set[k].size());
    }
    return;
}

int main()
{
    cin >> s;
    dfs(0);
    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 1792