akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>0){
        cout<<"Positive"<<endl;
    }
    else if(a<=0 && 0<=b){
        cout<<"Zero"<<endl;
    }
    else if((a+b)%2==0){
        cout<<"Negative"<<endl;
    }
    else{
        cout<<"Positive"<<endl;
    }
    return(0);
}

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

int main(void){
    int n;
    std::cin >> n;

    std::vector<int> f(n+1);


    f[0] = 1;
    f[1] = 1;
    
    for(int i = 2; i <= n; i++){
        f[i] = f[i-1] + f[i-2];
    }
    std::cout << f[n] << std::endl;
    
    

    return 0;
}


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

int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  
  	int t1,t2;
  	t1=a*b;
  	t2=c;
  
  if(t1<t2){
	cout << t1 << endl;
  }else if(t1>t2){
	cout << t2 << endl;
  }else{
   cout << t1 << endl; 
  }
  return 0;
}

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

int f[100010][2], n, si;
string s;

int main(){
  cin >> s;
  n = s.length();
  f[0][0] = f[0][1]=0;
  for (int i=0; i<n; ++i){
    si = s[i] - '0';
    f[i+1][si] = f[i][1-si];
    f[i+1][1-si] = f[i][si]+1;
  }
  cout << min(f[n][0], f[n][1]);
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define MAXN 1000001

using namespace std;

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

    int n, ans=0;
    cin >> n;
    vector<int> prime(MAXN, 0);
    for(int i=2; i*i<MAXN; i++){
        if(!prime[i])
            for(int j=i*i; j<MAXN; j+=i) prime[j]=i;
    }
    for(int i=2; i<MAXN; i++) if(!prime[i]) prime[i]=i;
    for(int c=1; c<n; c++){
        int d=n-c, res=1;
        while(d>1){
            int div=prime[d], cnt=0;
            while(d%div==0){
                cnt++;
                d/=div;
            }
            res=res*(cnt+1);
        }
        ans+=res;
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7152
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
int main()
{
    string a,b;
    cin >> a >> b;

    if(a.size()>b.size())
    {
        cout<<"GREATER"<<endl;
    }

    else if(a.size()<b.size())
    {
        cout<< "LESS" <<endl;
    }
    else
    {

        for(int i=0; i<a.size();i++)
        {
            if(a[i]>b[i])
            {
                cout<< "GREATER" <<endl;
                return 0;
            }
            else if(b[i]>a[i])
            {
                cout<<"LESS" << endl;;
                return 0;
            }
        }
        cout<< "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <class T> bool chmin(T& x, T y) {
    return x > y ? (x = y, true) : false;
}
int main() {
    string S; cin >> S;
    const int INF = 1e9;
    vector<int> A(1 << 26, INF);
    A[0] = 0;
    int hash = 0;
    for (int i = 0; i < S.size(); i++) {
        hash ^= 1 << (S[i] - 'a');
        int val = INF;
        chmin(val, A[hash] + 1);
        for (int j = 0; j < 26; j++) {
            chmin(val, A[hash ^ (1 << j)] + 1);
        }
        chmin(A[hash], val);
    }
    cout << max(1, A[hash]) << '\n';
    return 0;
}


Measured memory_bytes: 262660
#include <iostream>
#include <cstdlib>
#include <vector>

void print(std::vector<std::string>& readVec){
    int n = readVec.size();
    for(int i = 0; i < n; ++i){
        std::cout << readVec.at(i);
        if(n - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

int isOperator(std::string readStr){
    if(1 != readStr.size()){
        return 0;
    }

    switch(readStr.at(0)){
        case 42: // *
        case 43: // +
        case 45: // -
        case 47: // /
            return readStr.at(0);
            break;
        default:
            return 0;
            break;
    }
}

void getLR(std::vector<std::string>& readVec, long long& left, long long& right){
    left = std::atoll((readVec.end() - 2)->c_str());
    right = std::atoll((readVec.end() - 1)->c_str());
}

int main(){
    std::string str;
    std::vector<std::string> stack;
    while(std::cin >> str){
        long long left, right, val, flg = 0;
        switch(isOperator(str)){
            case 42:
                getLR(stack, left, right);
                val = left * right;
                ++flg;
                break;
            case 43:
                getLR(stack, left, right);
                val = left + right;
                ++flg;
                break;
            case 45:
                getLR(stack, left, right);
                val = left - right;
                ++flg;
                break;
            default:
                stack.push_back(str);
        }

        if(flg){
            auto itr = stack.end();
            *(itr - 2) = std::to_string(val);
            stack.erase(itr - 1, itr);
        }
    }

    std::cout << *stack.begin() << std::endl;

    return 0;
}


Measured memory_bytes: 3288
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

ans = False

for z in range(X+1,Y+1):
    x_flag = [x < z for x in x_list]
    y_flag = [y >= z for y in y_list]
    if sum(x_flag) == len(x_flag) and sum(y_flag) == len(y_flag):
        ans = True
        break

if ans:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var i int
	fmt.Scan(&i)
	fmt.Println(isCelebratingYear(i))
}

func isCelebratingYear(i int) string {
	if i == 7 || i == 5 || i == 3 {
		return "YES"
	}
	return "NO"
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

vi l;
vi bom(3, 0);
vi target(3);
int N, no=0;
ll res=INF;

void dfs(int id=0){
    if(id == N){
        ll sum=0;
        bool ok=true;
        for(int i=0; i<3; i++){
            if(bom[i] == 0) ok=false;
            sum+=abs(target[i]-bom[i]);
        }
        if(ok){
            sum+=(N-no-3)*10;
            res=min(res, sum);
        }
        return;
    }
    for(int i=-1; i<3; i++){
        if(i == -1){
            no++;
            dfs(id+1);
            no--;
        }
        else{
            bom[i]+=l[id];
            dfs(id+1);
            bom[i]-=l[id];
        }
    }
}

int main(){
    cin >> N;
    l.resize(N);
    for(auto &x: target) cin >> x;
    for(auto &x: l) cin >> x;
    dfs();
    cout << res << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    if(n<1200)
        cout<<"ABC"<<endl;
    else if(n>=1200&&n<2800)
        cout<<"ARC"<<endl;
    else
        cout<<"AGC"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  double a, b, c, d, e, f, x, y, det;
  while(cin >> a >> b >> c >> d >> e >> f) {
    det = 1.0/(a*e - b*d);
    x = (c*e - b*f)*det;
    y = (a*f - c*d)*det;

    if(x == 0) x = 0;
    if(y == 0) y = 0;

    printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n, m;
    cin >> n >> m;
    
    //sum = 1 + n*m - n;
    int sum = 1;
    
    int i = 0;
    for(i; sum<m; i++){
        sum += n -1;
    }
    
    int ans = i;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n = int(input())

x = pow(10, n, MOD)
y = pow(9, n, MOD)
z = pow(8, n, MOD)

ans = (((x - ((2 * y) % MOD) + MOD) % MOD) + z) % MOD

print(ans)


Measured memory_bytes: 61848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=200005,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    
    int N,M,K;cin>>N>>M>>K;
    
    ll ans=0;
    
    for(int i=0;i<=K;i++){
        ans+=comb(N-1,i)*M%mod*rui(M-1,N-i-1)%mod;
        ans%=mod;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 8348
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n, ans=0, ma=0;
    cin >> n;
    REP(i, n){
        int now=0, num=i;
        while(num % 2 == 0){
            num /= 2;
            now++;
        }
        if(ma <= now){
            ans=i;
            ma = now;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	ll x;
	cin >> x;
	ll ans = x / 11 * 2;
	ll eleven = 11;
	ll res = x % eleven;
	if (1<=res&&res <= 6)ans++;
	else if(res>6) {
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  
  sort(S.begin(), S.end());
  
  int count = 0;
  string unknown;
  
  for(int i = 0; i < N; i++){
    if(S.at(i) != unknown){
      count++;
      unknown = S.at(i);
    }
    
    else{
      continue;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 9548
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = 0;
    for ai in a {
        if ai % 2 == 1 {
            count += 1;
        }
    }
    println!("{}", if count % 2 == 0 { "YES" } else { "NO" });
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    rep(i,b){
        rep(j,a){
            if (a*i-b*j==c){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i = 1, x;
		Scanner sc = new Scanner(System.in);
		while (true) {
			x = sc.nextInt();
			if (x == 0) break;
			System.out.println("Case " + i++ + ": " + x);
		}
		sc.close();
	}
}


Measured memory_bytes: 42916
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  cin >> N;
  int tmp =1e9;
  int ans =0;
  int cnt =0;
  rep(i,N)
  {
    int B;
    cin >> B;
    if(B<0)cnt++;
    B = abs(B);
    ans += B;
    if(B<tmp) tmp = B;
  }
  if(cnt %2 != 0) ans -=2*tmp;
  cout << ans <<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define fi first
#define se second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<ll, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const double PI = acos(-1);
const double EPS = 1e-9;

int main()
{    
    ios::sync_with_stdio(false);cin.tie(0);
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int pos;
    cin>>pos;
    cout<<arr[pos-1]<<endl;
}
// PLUS ULTRA!
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans = a * c;
    if(ans < a * d){
        ans = a * d;
    }
    if(ans < b * d){
        ans = b * d;
    }
    if(ans < b * c){
        ans = b * c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long int ll;

int main(){
	ll sum = 0;
	ll ans = 0;
	ll mod = 1e9 + 7;
	int n;
	cin >> n;
	vector<ll> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		sum += v[i];
	for (int i = 0; i < n - 1; i++){
		sum -= v[i];
		ll tmp = (sum % mod) * v[i];
		ans = (ans + tmp) % mod;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4844
s = input()

#動的計画表で解決
s0 = len(s)


dp = [[0 for i in range(4)] for j in range(s0+1)]
dp[0][0]=1
mod = 10**9+7


for i in range(0,s0):
    if (s[i]=='A') or (s[i]=="?"):
        for j in range(0,4):
            dp[i+1][j]+= dp[i][j]
            dp[i+1][j]%=mod
        dp[i+1][1]+=dp[i][0]
        dp[i+1][1]%=mod

    if (s[i]=='B') or (s[i]=="?"):
        for j in range(0,4):
            dp[i+1][j]+= dp[i][j]
            dp[i+1][j]%=mod
        dp[i+1][2]+=dp[i][1]
        dp[i+1][2]%=mod

    if (s[i]=='C') or (s[i]=="?"):
        for j in range(0,4):
            dp[i+1][j]+= dp[i][j]
            dp[i+1][j]%=mod
        dp[i+1][3]+=dp[i][2]
        dp[i+1][3]%=mod
  
    
print(dp[s0][3])


Measured memory_bytes: 27632
h,w = map(int, input().split())
array = [input().split() for i in range(h)]

m = 0

for i in range(1,h-1):
    for j in range(1,w-1):
        if array[i][0][j] == '#' and ( array[i-1][0][j]=='.' and array[i+1][0][j]=='.' and array[i][0][j-1]=='.' and array[i][0][j+1]=='.'):
            m = m+1
        else:
            pass

for i in range(1,h-1):
    if array[i][0][0]=='#' and ( array[i-1][0][0]=='.' and array[i+1][0][0]=='.' and array[i][0][1]=='.'):
        m = m + 1
    else:
        pass

for i in range(1,h-1):
    if array[i][0][w-1]=='#' and ( array[i-1][0][w-1]=='.' and array[i+1][0][w-1]=='.' and array[i][0][w-2]=='.'):
        m = m + 1
    else:
        pass

for j in range(1,w-1):
    if array[0][0][j]=='#' and ( array[0][0][j-1]=='.' and array[0][0][j+1]=='.' and array[1][0][j]=='.'):
        m = m + 1
    else:
        pass

for j in range(1,w-1):
    if array[h-1][0][j]=='#' and ( array[h-1][0][j-1]=='.' and array[h-1][0][j+1]=='.' and array[h-2][0][j]=='.'):
        m = m + 1
    else:
        pass

if array[0][0][0]=='#' and ( array[0][0][1]=='.' and array[1][0][0]=='.'):
    m = m + 1
else:
    pass

if array[0][0][w-1]=='#' and ( array[0][0][w-2]=='.' and array[1][0][w-1]=='.'):
    m = m + 1
else:
    pass

if array[h-1][0][w-1]=='#' and ( array[h-1][0][w-2]=='.' and array[h-2][0][w-1]=='.'):
    m = m + 1
else:
    pass


if array[h-1][0][0]=='#' and ( array[h-2][0][0]=='.' and array[h-1][0][1]=='.'):
    m = m + 1
else:
    pass

if m>=1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3192
#include <stdio.h>
#define INF 1000000000
int N,c[100],r[100],A[100],m[100][100],p[200],s;
int Min(int x,int y){
  int tmp;
  if(x>=y) return y;
  else return x;
}


int matrixCO(){
  int n,i,l,k,q,j;
  n=s;

  for(l=2;l<=n;l++){
    for(i=1;i<n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=Min(m[i][j],q);
      }
    }
  }
  return m[i][j];

}

	
int main(){

  int i,min;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&r[i]);
    scanf("%d",&c[i]);
    p[s]=r[i];
    s++;
  }
  p[s]=c[i-1];
  s++;
  
  min=matrixCO();
  printf("%d\n",min);
  return 0;
}

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

int main ()
{
    int n,m,temp,i;
    cin >> n;
    vector <int> a;
    i = 0;
    int sum = 0;
    while (n--){
        cin>> temp;
         a.push_back(temp);
        sum = sum+temp;
        }

    cin >> m;
    while (m--)
    {
        cin >> i >> temp;
        temp = temp - a[i-1];
        cout << sum + temp<<"\n";
    }
    return 0;
    }


Measured memory_bytes: 3616
N = int(input())

if N%2 == 0 or N == 5:
    print(-1)
    quit()
    
temp = 7%N
ans = 1
while temp != 0:
    temp = (temp*10+7)%N
    ans += 1
    if ans >= 10**6+1000:
        print(-1)
        quit()
print(ans)


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

int main() {
  string S;
  cin >> S;
  int mm = (S[5] - '0') * 10 + S[6] - '0';
  if (mm <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) rep2(i,0,n)

using namespace std;


main(){
    ll int n;
    cin>>n;
    ll int a[n];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll int max=a[n-1];
    ll int *pos;
    pos=lower_bound(a,a+n,max/2);
    ll int c1=*pos;
    ll int c2=*(pos-1);
    if(c1==a[0]) cout<<max<<" "<<c1;
    else if(c1==max) cout<<max<<" "<<c2;
    else if(max-c1>=c2) cout<<max<<" "<<c1;
    else cout<<max<<" "<<c2;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    int n = s.size();
    int m = t.size();

    const string UNR = "UNRESTORABLE";
    string ret = UNR;

    rep(i,n-m+1)
    {
        string u = s;
        bool replacable = true;
        rep(j,n)
        {
            if(j>=i && j<i+m)
            {
                if(u[j]=='?')
                    u[j] = t[j-i];
                else if(u[j]!=t[j-i])
                {
                    replacable = false;
                    break;
                }
            }
            else if(u[j]=='?')
                u[j] = 'a';
        }

        if(replacable)
            if(ret==UNR || u<ret)
                ret = u;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    string s,t;
    cin >> s >> t;
    int ans=10000;
    for ( int i=0; i<=SZ(s)-SZ(t); i++ ) {
        int res=0;
        for ( int j=0; j<SZ(t); j++ ) {
            if ( s[i+j]!=t[j] ) res++;
        }
        chmin(ans,res);
    }

    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
struct data {
    int d[7];
} dice;
 
int search(int a)
{
    int i;
 
    for(i=1;i<=6;i++){
        if(dice.d[i] == a)
            return i;
    }
}
 
int main(void)
{
    int q;
    int i, j, tmp, a, b;
 
 
    for(i=1;i<=6;i++)
        scanf("%d", &dice.d[i]);
    scanf("%d", &q);
 
    for(i=0;i<q;i++){
        scanf("%d %d", &a, &b);
 
         
        switch(search(a)){
            case 4 :    tmp = dice.d[3];
                        dice.d[3] = dice.d[1];
                        dice.d[1] = dice.d[4];
                        dice.d[4] = dice.d[6];
                        dice.d[6] = tmp;
                        break;
            case 2 :    tmp = dice.d[5];
                        dice.d[5] = dice.d[1];
                        dice.d[1] = dice.d[2];
                        dice.d[2] = dice.d[6];
                        dice.d[6] = tmp;
                        break;
            case 5 :    tmp = dice.d[2];
                        dice.d[2] = dice.d[1];
                        dice.d[1] = dice.d[5];
                        dice.d[5] = dice.d[6];
                        dice.d[6] = tmp;
                        break;
            case 3 :    tmp = dice.d[4];
                        dice.d[4] = dice.d[1];
                        dice.d[1] = dice.d[3];
                        dice.d[3] = dice.d[6];
                        dice.d[6] = tmp;
                        break;
            case 6 :    tmp = dice.d[6];
                        dice.d[6] = dice.d[1];
                        dice.d[1] = tmp;
                        tmp = dice.d[3];
                        dice.d[3] = dice.d[4];
                        dice.d[4] = tmp;
                        break;
        }
 
        while(dice.d[2] != b){
            tmp = dice.d[2];
            dice.d[2] = dice.d[3];
            dice.d[3] = dice.d[5];
            dice.d[5] = dice.d[4];
            dice.d[4] = tmp;
        }
 
        printf("%d\n", dice.d[3]);
    }
 
    return 0;
}

Measured memory_bytes: 1188
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    string s;
    cin>>s;
    int cons=0;
    int maxx=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R')cons++;
        else{
           
            maxx=max(cons,maxx);
             cons=0;
        }
    }
    maxx=max(cons,maxx);
    cout << maxx << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <array>
#include <cmath>

int main(int argc, char const *argv[])
{
	std::array<int,3> a;
	int k;
	std::cin >> a[0] >> a[1] >> a[2] >> k;

	std::sort(a.begin(),a.end());
	std::cout << a[0]+a[1]+(a[2]*pow(2,k));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	map<ll,ll> mp;
	ll n, x; scanf("%lld", &n);
	ll tot = 0;
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		tot += x;
		mp[x]++;
	}
	ll q, b, c, cnt;
	scanf("%lld", &q);
	while(q--){
		scanf("%lld %lld", &b, &c);
		cnt = mp[b];
		mp[b]=0;
		mp.erase(b);
		tot -= (b * cnt);
		tot += (c * cnt);
		mp[c]+= cnt;
		printf("%lld\n", tot);
	}
	return 0;
}

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

using namespace std;

int a[100005];

int in()
{
    int a;
    scanf("%d",&a);
    return a;
}

int main()
{
    int n=in(),ans=0;
    for(int i=0;i<n;i++)
    {
        int aa=in();
        if(aa>100000)
            ans++;
        else
            a[aa]++;
    }
    for(int i=1;i<=100000;i++)
    {
        if(a[i]>i){
            ans+=(a[i]-i);
        }
        else if(a[i]<i)
        ans+=a[i];
    }
    printf("%d\n",ans);
}


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

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        String S = next();
        String T = next();
        if (S.equals(T)) {
            out.println(0);
            return;
        }
        int j = n - 1;
        int res = 0;
        int[] q = new int[n + 1];
        int h = 0;
        int t = 0;
        int d = 0;
        int jj = n;
        for (int i = n - 1; i >= 0; i--) {
            if (j > i) j = i;
            while (j >= 0 && S.charAt(j) != T.charAt(i)) j--;
            if (j < 0) {
                out.println(-1);
                return;
            }
            while (t > h) {
                int xx = q[h] - d;
                if (xx > i) {
                    h++;
                } else {
                    break;
                }
            }
            if (j < i && j != jj) {
                d++;
                q[t++] = (j + d);
                res = Math.max(res, t - h);
            }
            jj = j;
//            System.out.println(i + " " + j);
//            for (int e = h; e < t; e++) {
//                System.out.println(q[e] - d);
//            }
        }
        out.println(res);
    }

    private BufferedReader br;
    private PrintWriter out;
    private StringTokenizer st;

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

}


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

const ll INF = 1e18;

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

    int N;
    cin >> N;

    vector<ll> A(N);
    for (auto &x : A) {
        cin >> x;
        if (x == 0) {
            cout << 0 << endl;
            exit(0);
        }
    }

    ll ans = 1;
    for (auto &x : A) {
        if (x > INF / ans) {
            ans = -1;
            break;
        }
        ans *= x;
    }

    cout << ans << endl;

    return 0;
}

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

int gcd(int a, int b) {
  int tmp;
  while ( a%b != 0 ) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int m = gcd(a, b);
  vector<int> div;
  for ( int i = 1; i <= sqrt(m); i++ ) {
    if ( m%i == 0 ) {
      div.push_back(i);
      if ( m/i != i ) { div.push_back(m/i); }
    }
  }
  sort(div.begin(), div.end());

  cout << div[div.size()-k] << endl;
  return 0;
}


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

const int maxn = 105;
int a[maxn];
int N;
int K;
int DP[100005];
// DP[i] = 1 if there are i stones in pile and first player wins
// DP[i] = 0 if there are i stones in pile and first player loses

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= K; ++i){
        for(int j = 1; j <= N && DP[i] == 0; ++j){
            if(i - a[j] >= 0){
                DP[i] |= !DP[i - a[j]];
            }
        }
    }
    if(DP[K]){
        cout << "First\n";
    }
    else{
        cout << "Second\n";
    }
}


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

int main()
{
    long long int x,d,k,ans,curr,curr1,ret;
  	cin>>x>>k>>d;
  	x=abs(x);
  	curr=x;
  	if(x%d==0){
      ret=x/d;
    }else{
      ret=x/d+1;
    }
  	if(ret==k || ret>k){
      ans=x-k*d;
      printf("%lld\n",abs(ans));
    }else{
      k=k-ret;
      curr=x-ret*d;
      curr1=curr+d;
      if(k%2==0){
        printf("%lld\n",abs(curr));
      }else{
        printf("%lld\n",abs(curr1));
      }
    }
    return 0;
}

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

using namespace std;
using ll = long long;

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

	ll ans = 0;
	map<int, int> cnt;

	for(int i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		ans += cnt[a - i];
		cnt[-a - i]++;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 20688
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    long long int q,h,s,d, n;
    cin >> q >> h >> s >> d >> n;
    long long int sum = 0,sum2 = 0,sum3 = 0,sum4 = 0;
    sum2 = n * s;
    sum3 = (n * 2) * h;
    sum4 = (n * 4) * q;
    sum = (n / 2)*d;
    if(n % 2 == 1){
        sum += min(s,min(2*h,4*q));
    }
    sum2 = min(sum,sum2);
    sum2 = min(sum2,sum3);
    cout << min(sum2,sum4) << endl;
}


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

int N; ll K;
vector<ll> A;
//全通りからK番目を求めるという問題は実は典型で，二分探索で解く

ll getMinus(ll lim) {
  vector<ll> mi, pl;
  for (int i = 0; i < N; i++) {
    if (A[i] < 0) mi.push_back(A[i]);
    if (A[i] > 0) pl.push_back(A[i]);
  }

  int right = 0;
  ll res = 0;
  for (int left = 0; left < mi.size(); left++) {
    //m*pがlim以下の数を数える
    //しゃくとり法を使う
    while (right < pl.size() && lim < mi[left] * pl[right]) right ++;
    res += pl.size() - right;
  }
  return res;
}

ll getZeros() {
  int zero = 0;
  for (int i = 0; i < N; i++) if (A[i] == 0) zero ++;
  return 1LL * zero * (N-zero) + 1LL * zero * (zero-1) / 2;
}

ll getPlus(ll lim) {
  vector<ll> mi, pl;
  for (int i = 0; i < N; i++) if (A[i] > 0) pl.push_back(A[i]);
  for (int i = N-1; i >= 0; i--) if (A[i] < 0) mi.push_back(-A[i]);

  ll res = 0;

  int right = mi.size()-1;

  for (int left = 0; left < mi.size(); left++) {
    while (left < right && lim < mi[left] * mi[right]) right --;
    res += right - left;
    if (right == left) right ++;
  }

  right = pl.size()-1;

  for (int left = 0; left < pl.size(); left++) {
    while (left < right && lim < pl[left] * pl[right]) right --;
    res += right - left;
    if (right == left) right ++;
  }

  return res;
}

ll getCount(ll lim) {
  ll res = getMinus(lim);
  if (lim >= 0) res += getZeros();
  if (lim > 0) res += getPlus(lim);
  return res;
}

int main() {
  cin >> N >> K;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll INF = 1LL << 60;
  ll upper = INF, lower = -INF;
  ll mid;
  while(upper > lower + 1) {
    mid = (lower+upper)/2;
    if (getCount(mid) >= K) upper = mid;
    else lower = mid;
  }
  cout << upper << endl;
}

Measured memory_bytes: 5236
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include "unistd.h"

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;


int n, m, q;
int a[50], b[50], c[50], d[50];
int result = 0;
map<v, int> memo;

bool isValid(v &target) {
  rep(i, n - 1) {
    if(target[i] > target[i + 1]) return false;
  }
  if(target[n- 1] > m) return false;
  return true;
}

void dfs(v &target) {
  if(isValid(target)) {
    if(memo.count(target)) return;
    memo[target] = 1;
    int point = 0;
    rep(i, q) {
      if(target[b[i] - 1] - target[a[i] - 1] == c[i]) point += d[i];
    }
    result = max(result, point);
    rep(i, n) {
      v temp = target;
      temp[i]++;
      dfs(temp);
    }
  }
}

int main()
{
  cin >> n >> m >> q;
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  v start(n, 1);
  dfs(start);
  cout << result << endl;
}


Measured memory_bytes: 15124
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int n;
int a;
map<int,int> G;

int main(){
    cin>>n;
    rep(i,0,n){
        cin>>a;
        G[a]++;
    }

    ll ans=0;
    for(auto it=G.begin();it!=G.end();it++){
        if(it->second<it->first) ans+=it->second;
        else ans+=(it->second-it->first);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int w,n;
  cin>>w>>n;
  vi ans(w);
  rep(i,w)ans[i]=i+1;
  rep(i,n){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(ans[a-1],ans[b-1]);
  }
  rep(i,w)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    cout << A[0]+A[1] << endl;
    

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**9
for i in range(n - k + 1):
    cand = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
    ans = min(ans, cand)

print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <functional>

using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n, m, c);
    Cins(int, m, b);
    int ans = 0;
    Rep(n){
        Cins(int, m, a);
        int acc = c;
        For(i, m) acc += a[i]*b[i];
        if(acc > 0) ans ++;
    }
    Cout(ans);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.*;
import java.math.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			long ss = sc.nextLong();
			if(ss == 0) break;
			boolean minus = false;
			if(ss < 0) minus = true;
			char[] in = String.valueOf(ss).toCharArray();
			int[] ar0 = new int[64];
			int[] ar1 = new int[64];
			for(int i = 0; i < in.length; i++) {
				if(in[in.length - i - 1] == '-') continue;
				ar0[i] = in[in.length -1 - i] - '0';
			}
			if(!minus)
			for(int i = 0; i < 64; i++) {
				if(ar0[i] == 0) continue;
				if(i % 2 == 0) {
					if(ar0[i] < 10) {
						ar1[i] += ar0[i];
					}
					else {
						ar0[i+1] += ar0[i]/10;
						ar1[i] += ar0[i] % 10;
					}
				}
				else {
					if(ar0[i] < 10) {
						ar1[i] += 10 - ar0[i] % 10;
						ar0[i+1] += 1;
					}
					else {
						ar0[i+1] += ar0[i] / 10;
						if(ar0[i] % 10 != 0)
						ar1[i] += 10 - ar0[i] % 10;
						if(ar0[i] % 10 != 0)
						ar0[i+1] += 1;
					}
				}
			}
			else {
				for(int i = 0; i < 64; i++) {
					if(ar0[i] == 0) continue;
					if(i % 2 != 0) {
						if(ar0[i] < 10) {
							ar1[i] += ar0[i];
						}
						else {
							ar0[i+1] += ar0[i]/10;
							ar1[i] += ar0[i] % 10;
						}
					}
					else {
						if(ar0[i] < 10) {
							ar1[i] += 10 - ar0[i] % 10;
							ar0[i+1] += 1;
						}
						else {
							ar0[i+1] += ar0[i] / 10;
							if(ar0[i] % 10 != 0)
							ar1[i] += 10 - ar0[i] % 10;
							if(ar0[i] % 10 != 0)
							ar0[i+1] += 1;
						}
					}
				}
			}
			int check = 0;
			for(int i = 0; i < 64; i++) {
				if(ar1[i] != 0) {
					check = i;
				}
			}
			String a = "";
			for(int i = check; i >= 0; i--) {
				a += ar1[i];
			}
			
			System.out.println(Integer.parseInt(a));
		}
	}
	
}

Measured memory_bytes: 29020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H, N, sum=0;
    cin>>H>>N;

    int arr[N];

    for(int i=0;i<N;i++)
     {
         cin>>arr[N];
         sum=sum+arr[N];
     }

     if(sum>=H)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int tmp=1;
  ll ans=0;
  rep(i,N){
    ans+=(A[i]-1)/tmp;
    if((tmp==1 and i==0) or A[i]==tmp) tmp++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    char tmp;
    string S;
    cin >> A>> B>>C;

    if(A==B && B==C)
	ans =1;
    else if(A==B || B==C || C==A)
	ans =2;
    else
	ans = 3;
    
    
    // ans = max(A*B, C*D);
    
    cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	long long a,b,c,ans = 0,aa,bb,cc;
	scanf("%lld %lld %lld",&a,&b,&c);
	while(1){
		if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
			printf("%lld",ans);
			return 0;
		}
		aa = a / 2;
		bb = b / 2;
		cc = c / 2;
		a = bb + cc;
		b = aa + cc;
		c = aa + bb;
		ans++;
		if(ans > 1e7) break;
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split(" "))
LR = [input() for _ in range(M)]

left = 1
right = N
for i in LR:
    Li, Ri = map(int, i.split(" "))
    left = max(left, Li)
    right = min(right, Ri)

if right < left:
    print(0)
else:
    print(right - left + 1)


Measured memory_bytes: 10272