akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ans=min(ans*2,ans+k);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;

public class Progaram
{

    public static void Main()
    {
        var s = Console.ReadLine();
        var n = s.Length;
        var a = s.Select(t => t - '0').ToArray();
        var t = new int[n + 1];
        var magnitudeMod = 1;
        t[n] = 0;
        t[n - 1] = a[n - 1];
        for (int k = n - 2; k >= 0; k--)
        {
            magnitudeMod = magnitudeMod * 10 % 2019;
            t[k] = (t[k + 1] + a[k] * magnitudeMod) % 2019;
        }
        var counts = t.GroupBy(t => t)
            .Select(t => (t.Count() * (t.Count() - 1) / 2))
            .ToArray();
        Console.WriteLine(counts.Sum());
    }
}

Measured memory_bytes: 32632
//
// Created by rajshah9914 on 28/03/20.
//


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=INT_MAX,k,n,a[200010];
    cin>>k>>n;
    vector<long long>b;
    for(long long i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    b.push_back(a[0]);
    long long sum=a[0];
    for(long long i=1;i<n;i++)
    {
        sum+=a[i]-a[i-1];
        b.push_back(a[i]-a[i-1]);
    }
    b.push_back(k-a[n-1]+a[0]);
    sum+=k-a[n-1]+a[0];
    for(long long i=0;i<b.size();i++)
    {
//        cout<<b[i]<<" ";
        ans=min(ans,k-b[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 
    int a,b,c;
 
    cin>>a>>b>>c;
 
    if(a==5 && b==5 && c==7)
    {
        cout<<"YES"<<endl;
    }
    else if(a==7 && b==5 && c==5)
    {
        cout<<"YES"<<endl;
    }
    else if(a==5 && b==7 && c==5)
    {
       cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int K; cin >> K;
    char target = S[K-1];
    REP(i,N) if(S[i]!=target) S[i] = '*';
    cout << S << '\n';

    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long X);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
}

void solve(long long X){
    cout << (8-(X-400)/200) << el;
}



Measured memory_bytes: 3756
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int N,M,C,ans=0;
    cin >> N >> M >> C;
    long long b[25];
    long long a[25][25];
    for(int i=0; i<M; i++){
        cin >> b[i];
    }
    rep(i,N){
        rep(j,M)
            cin >> a[i][j];
    }
    int mm=0;
    rep(i,N){
        mm = 0;
        rep(j,M){
            mm+=a[i][j]*b[j];
        }
        if(mm+C > 0) ans++;

    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n, l;
  vector<string> v;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  for(int i=0;i<n;i++){
    cout << v[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
ll inf(1e18);
#define mod ll(1e9+7)
//#define mod ll(998244353)
#define ff first
#define ss second
ll power(ll a,ll b)
{
	if(!b)
		return 1;
	ll dp=power(a,b/2)%mod;
	
	if(b&1) return (((dp*dp)%mod)*a)%mod;
	
	return (dp*dp)%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
    //cin>>test;

    while(test--)
    {
		ll n;
		cin>>n;
		vector<ll> a(n),b(n);
		
		for(ll i=0;i<n;++i)
		cin>>a[i]>>b[i];
		
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		
		ll left,right;
		if(n&1)
		{
			left=a[n/2];
			right=b[n/2];
			cout<<right-left+1;
		}
		else {
			left=a[n/2]+a[n/2-1];
			right=b[n/2]+b[n/2-1];
			cout<<(right-left)+1;
		}
			
	}
	return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); i++) {
		if(s[i] + n <= 90) {
			s[i] = s[i] + n;
		}
		else {
			s[i] = s[i] + n -26;
		}
		
	}
	cout << s;
	
	
	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,ans=0;
  cin >> n;
  string s;
  for(int i=1; i<=n; i++) {
    s=to_string(i);
    if(s.size()%2==1) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll=long long;

// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}

void solve() {
    int n; cin >> n;
    ll x, y;
    cin >> x >> y;
    for (int _ = 1; _ < n; _++) {
        ll p,q;
        cin >> p >> q;
        ll lim = 2e18/(max(p,q));
        ll t = bs_first<ll>(1, lim, [&](ll t){
                return p*t>=x && q*t>=y;
                });
        x = p*t;
        y = q*t;
    }
    cout << (x+y);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
signed main(){
/*int a,b;
scanf("%d%d",&a,&b);
int c[100001];
for(int d=0;d<a;d++)cin>>c[d+1];
c[0]=c[2];c[a]=c[a-2];
priority_queue<P,vector<P>,greater<P>>Q;
for(int e=0;e<a;e++){
    if(c[e]<c[e+1]&&c[e+1]>c[e+2])Q.push(P(b-c[e+1],e+1));
    }
    int MAX=0;
    while(Q.size()){
          P f=Q.top();
	  Q.pop();
	  MAX=max(MAX,f.second);
	  c[f.second]=0;
	  c[0]=c[2];c[a]=c[a-2];
	  if(f.second>1&&c[f.second-1]){
	      if(c[f.second-2]<c[f.second-1]&&c[f.second-1]>c[f.second])Q.push(P(f.first+b-c[f.second-1],f.second-1));
	      }
	  if(f.second<a-1&&c[f.second+1]){
	      if(c[f.second+2]<c[f.second+1]&&c[f.second+1]>c[f.second])Q.push(P(f.first+b-c[f.second+1],f.second+1));
	      }
	}
	printf("%d\n",MAX);*/
	int a;
	cin>>a;
	cout<<a*a*a<<endl;
}

Measured memory_bytes: 3104
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

string s;

signed main() {
    cin >> s;
    if (s[1] == 'R') {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}


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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)

	int solve()
	{
		string s;
		cin >> s;
		if(s=="ARC") cout<<"ABC";
		else cout<<"ARC";
      return 0;
	}

	int32_t main()
	{

	  #ifndef ONLINE_JUDGE
	  freopen("input.txt","r",stdin);
	  freopen("output.txt","w",stdout);
	  #endif
	  int t=1;
	  //cin >>t;
	  while(t--) solve();

	}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, a, b;

int main()
{
    cin>>n>>a>>b;
    if(a % 2 == b % 2)
    {
        cout<<(b - a) / 2;
    }
    else
    {
        ll ans2 = 9e18;
        ll ans = 0;
        ll aa = a, bb = b;
        ans += aa;
        bb -= aa, aa = 1;
        ans += (bb - 1) / 2;
        ans2 = min(ans2, ans);
        aa = n - b + 1;
        bb = n - a + 1;
        ans = 0;
        ans += aa;
        bb -= aa, aa = 1;
        ans += (bb - 1) / 2;
        ans2 = min(ans2, ans);
        cout<<ans2;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println(6-A-B);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);  
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
       ios_base::sync_with_stdio(false);  
       cin.tie(NULL);
string s ,t;
cin>>s>>t;
int n = s.size();
int m = t.size();
int minn = INT_MAX;
for(int i = 0 ; i < n - m + 1; i++){
	int cur = 0;
	for(int j = 0; j < m ;j++){
		if(s[i + j] != t[j]){
			cur++;   
		}  
	}
		if(cur < minn)
			minn = cur;
	}
	cout<<minn<<endl;
}

Measured memory_bytes: 3684
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll sum(ll n){return n*(n+1)/2;} 

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=0, Min=3e9+1;
  string s,t;
  VL a(3),b(3);
  rep(i,3){
    cin >> a[i];
  }
  sort(ALL(a));
  Max = a[2];
  rep(i,3){
    b[i]= Max - a[i];
  }
  ans += b[1];
  b[0] -= b[1];
  if(b[0]%2==0){
    ans += (b[0]/2);
  }
  else{
     ans = ans + (b[0]/2) + 2; 
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y;
int main() {
	cin>>a>>b>>c>>x>>y;
	cout<< min({a*x+b*y,c*2*max(x,y),c*2*min(x,y)+(x>y?a*(x-y):b*(y-x))})<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        h: [usize; n],
    }
    const W: usize = 700;
    const INF: f64 = 1e18;
    let mut dp = vec![vec![INF; W]; n + 1];
    dp[0][1] = 0.0;
    for i in 0..n {
        for j in 1..W {
            for k in 1..W {
                let u = j as f64 - h[i] as f64;
                let v = k as f64 - h[i] as f64;
                let cost;
                if u == 0.0 && v == 0.0 {
                    cost = 0.0;
                } else if u * v > 0.0 {
                    cost = (u + v).abs() / 2.0;
                } else {
                    cost = (u * u + v * v) / (u - v).abs() / 2.0;
                }
                let val = dp[i][j] + cost;
                if dp[i + 1][k] > val {
                    dp[i + 1][k] = val;
                }
            }
        }
    }
    let mut mi = INF;
    for i in 1..W {
        if mi > dp[n][i] {
            mi = dp[n][i];
        }
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;


void countingSort(vector<int>& A, vector<int>& B, int k)
{
  int n = A.size();
  vector<int> freqs(k + 1, 0);
  for (int i = 0; i < n; ++i) { ++freqs[A[i]]; }
  for (int i = 1; i <= k; ++i) { freqs[i] += freqs[i - 1]; }
  for (int i = n - 1; i >= 0; --i) {
    B[freqs[A[i]] - 1] = A[i];
    --freqs[A[i]];
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n), B(n);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
    k = max(k, A[i]);
  }
  countingSort(A, B, k);
  for (int i = 0; i < n; ++i) {
    if (i) { fprintf(stdout, " "); }
    fprintf(stdout, "%d", B[i]);
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 16764
H, W = map(int, raw_input().split())
G = [raw_input().strip() for _ in xrange(H)]
dp = [[0 for i in xrange(W)] for _ in xrange(H)]
mod = 10**9 + 7

dp[0][0] = 1 if G[0][0] == '.' else 0

for i in xrange(H):
    for j in xrange(W):
        if i + 1 < H and G[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
        if j + 1 < W and G[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print dp[H-1][W-1]





Measured memory_bytes: 42092
#include <stdio.h>

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

int bubbleSort(int A[],int N) {
  int i,j;
  int sw = 0;
  unsigned short flag = 1;
  for(i=0;flag;i++) {
    flag = 0;
    for(j=N-1;j>=i+1;j--) {
      if(A[j]<A[j-1]) {
        swap(&A[j],&A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(void) {
  int i, A[100], N, sw;
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  sw = bubbleSort(A,N);

  for(i=0;i<N;i++) {
    if (i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",sw);

  return 0;
}


Measured memory_bytes: 2100
from fractions import *
from itertools import *
N = int(input())
A = list(map(int,input().split()))
B = list(accumulate([0]+A,gcd))
C = list(accumulate([0]+A[::-1],gcd))
print(max(gcd(s,t)for s,t in zip(B,C[::-1][1:])))

Measured memory_bytes: 16056
N,M=map(int,input().split())
a = "a"+input()+"q"
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 1
t = N
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
  if j == "L" and i == a[s]:
    s+=1
  if j == "R" and i == a[s-1] and s> 1:
    s-=1
  if j == "L" and i == a[t+1] and t< N:
    t+=1
  if s==t+1 and N!=0:break
if N>1:print(t-s+1)
else: 
  if s+c+1>1:print(1)
  else:print(0)

Measured memory_bytes: 25748
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        boolean found = false;
        for (int i = 1; i <= 9; i++) {
            if (N % i != 0) {
                continue;
            }
            if (N / i <= 9) {
                found = true;
                break;
            }
        }
        if (found) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1), b(n);
  rep(i, 0, n + 1) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  ll j = 0, mx = 0;
  rep(i, 0, n) {
    if (a[i] == b[i]) {
      mx += a[i];
      a[i] = 0;
    } else if (a[i] > b[i]) {
      mx += b[i];
      a[i] = a[i] - b[i];
    } else if (a[i] < b[i]) {
      mx += a[i];
      b[i] = b[i] - a[i];
      if (a[i + 1] == b[i]) {
        mx += b[i];
        a[i + 1] = 0;
      } else if (a[i + 1] < b[i]) {
        mx += a[i + 1];
        a[i + 1] = 0;
      } else if (a[i + 1] > b[i]) {
        mx += b[i];
        a[i + 1] = a[i + 1] - b[i];
      }
    }
  }
  cout<<mx;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n) {
	return 0;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));
}


int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans_area =double(w) * double(h) / 2;


	if (2 * x == w && 2 * y == h){
		cout <<fixed <<setprecision(8)<< ans_area << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(8) << ans_area << " " << 0 << endl;
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 504
// インクルード(GCC only)
#include <bits/stdc++.h>

// 長い型名
using namespace std;
typedef long long LL;

// 省略記法
#define INF 1e9
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n), i=(i##_len-1); i>=0; ++i)
#define FOR(i,m,n) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define all(x) (x).cbegin(),(x).cend()
#define sizei(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define printvector(x) rep(i,sizei(x)){cout << x[i] << endl;}
#define summation(x) (accumulate(all(x), 0LL))
#define product(x) (accumulate(all(x), 1LL, [](int acc, int i) { return acc * i;}))

// mod付き四則演算(mod関数のオーバーヘッドが重いかも)
// TODO: 二項係数、離散対数、平方剰余の実装
//#define MOD 1000000007LL
#define MOD 998244353LL
inline LL mod(LL const &a) { return (a % MOD + MOD) % MOD; }
inline LL madd(LL const &a, LL const &b) { return mod(mod(a) + mod(b)); }
inline LL msub(LL const &a, LL const &b) { return mod(mod(a) - mod(b)); }
inline LL mmul(LL const &a, LL const &b) { return mod(mod(a) * mod(b)); }
inline LL mpow(LL a, LL b) {
  LL r = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) (r *= a) %= MOD;
    (a *= a) %= MOD;
  }
  return r;
}
inline LL minv(LL const &a) { return mpow(a, MOD-2); }
inline LL mdiv(LL const &a, LL const &b) { return mod(mod(a) * minv(b)); }


// デバッグ用
#ifdef LOCAL
    #define TO_STRING(VariableName) # VariableName
    #define eprint(...) {fprintf(stderr, "DEBUG: "); fprintf(stderr, __VA_ARGS__);}
    #define eprintvector(x) rep(i,sizei(x)){fprintf(stderr, "DEBUG: %s[%d] = %lld\n", TO_STRING(x), i, x[i]);}
#else
    #define eprint(...) 42
    #define eprintvector(x) 42
#endif

/**************** 便利な関数 ****************/
vector<string> split_impl(string &&s, regex &&r) { return { sregex_token_iterator{s.begin(), s.end(), r, -1}, sregex_token_iterator{} }; }
auto split(string s, string pattern) { return split_impl(move(s), regex{pattern}); }
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; }


/**************** ラムダ再帰用 ****************/
template<typename F>
class FixPoint : F
{
public:
  explicit constexpr FixPoint(F&& f) noexcept
    : F(std::forward<F>(f))
  {}
 
  template<typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
 
template<typename F>
static inline constexpr decltype(auto)
makeFixPoint(F&& f) noexcept
{
  return FixPoint<F>{std::forward<F>(f)};
}

/**************** main ****************/
 
int main()
{
  LL N, K;
  cin >> N >> K;

  vector<LL> h(N+1);
  FOR(i, 1, N+1) {
    cin >> h[i];
  }

  vector<LL> dp(N+1, INF);
  dp[1] = 0;

  FOR(i, 1, N+1) {
    FOR(k, 1, K+1) {
      if (i+k > N) break;
      chmin(dp[i+k], dp[i] + abs(h[i] - h[i+k]));
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 1792
def main() -> None:
    a, b = map(int, input().split())
    h = 0
    for i in range(1, 1000):
        if (h - a) == (h + i - b):
            print("{}".format(h - a))
            break
        else:
            h = h + i


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std;
#define ll long long;
#define llu unsigned long long;
int main()
{
	string S;
	cin>>S;
	if(S[2]==S[3]&&S[4]==S[5])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;

int n,t[55],c[55];

int main(){
  while(cin>>n,n){
    vector<P>v;
    r(i,n)cin>>t[i]>>c[i];
    r(i,n)v.push_back(P(t[i],i));
    sort(v.begin(),v.end());
    queue<P2>q[2];
    r(i,n)q[0].push(P2(v[i].fi,P(v[i].se,c[v[i].se])));
    int cur=0,ans=0;
    while(q[0].size()+q[1].size()){
      vector<P2>v;
      if(q[cur].empty())cur^=1;
      else if(q[cur^1].size()&&q[cur].front().fi>q[cur^1].front().fi)cur^=1;
      int nxt=q[cur].front().fi;
      while(!q[cur].empty()&&q[cur].front().fi<=nxt){
        v.push_back(q[cur].front());
        v[v.size()-1].fi=nxt+t[v[v.size()-1].se.fi];
        q[cur].pop();
      }
      sort(v.begin(),v.end());
      r(i,v.size()){
        if(cur==1)v[i].se.se--;
        if(v[i].se.se==0)ans=nxt;
        else q[cur^1].push(v[i]);
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 Graph = vector<vector<int>>;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<bitset<20>> X(N);
    int sum = 0;
    rep(i, N) {
        cin >> A[i];
        X[i] = A[i];
        sum ^= A[i];
    }

    rep(i, N)
    {
        cout << (A[i] ^ sum) << endl;
    }
    return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  	int len_array,min_ = 10000000,temp;
  	int counter = 0;
  	scanf("%d",&len_array);
  	for(int i = 0;i < len_array;i++){
    	scanf("%d",&temp);
      	min_ = min(min_,temp);
      	if(temp <= min_) counter++;
    }
  	printf("%d\n",counter);
    return 0;   
}

Measured memory_bytes: 256
W,H = map(int,input().split())
PQ = [(int(input()),0) for _ in [0]*W] + [(int(input()),1) for _ in [0]*H]
PQ.sort()
r = H+1
c = W+1
ans = 0
for d,pq in PQ:
    if pq==0:
        ans += d*r
        c -=1
    else:
        ans += d*c
        r -=1
print(ans)

Measured memory_bytes: 26008
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
                    
                    String[] temp = str.split("\\s");
                    
                    int r = Integer.parseInt(temp[0]);
                    int c = Integer.parseInt(temp[1]);
                    int[][] inp = new int[r][c];
                    
                    

                    for(int i=0;i<r;i++){
                        str = br.readLine();
                        String[] line = str.split("\\s");
                            for(int j=0; j<c; j++){
                                int x = Integer.parseInt(line[j]);
                                inp[i][j]= x;
                            }
                    }

                    
                    int[] ve = new int[c];
                    for(int k=0; k<c ; k++){
                        str = br.readLine();
                        String[] strs = str.split("\\s");
                        ve[k] = Integer.parseInt(strs[0]);
                        //System.out.println(ve[k]);
                    }
                    
                    for(int i=0;i<r;i++){
                        int ans =0;
                        int atemp = 0;
                        for(int j =0;j<c;j++){
                         atemp = inp[i][j] * ve[j];
                         ans += atemp;  
                        }
                        System.out.println(ans);
                    }
                        br.close();
    }
}

Measured memory_bytes: 28512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

    if(u==s) a--;
    else if(u==t) b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

inline int mask(std::initializer_list<int> x){
	int answer = 0;
	for(const auto s : x){ answer |= (1 << s); }
	return answer;
}

static int POPCNT[1 << 7];
static const int TABLE[] = {
	mask({ 0, 1, 2, 4, 5, 6 }),
	mask({ 2, 5 }),
	mask({ 0, 2, 3, 4, 6 }),
	mask({ 0, 2, 3, 5, 6 }),
	mask({ 1, 2, 3, 5 }),
	mask({ 0, 1, 3, 5, 6 }),
	mask({ 0, 1, 3, 4, 5, 6 }),
	mask({ 0, 2, 5 }),
	mask({ 0, 1, 2, 3, 4, 5, 6 }),
	mask({ 0, 1, 2, 3, 5, 6 })
};
static const int MONTH_TABLE[] = {
	0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

int main(){
	ios_base::sync_with_stdio(false);
	for(int i = 0; i < (1 << 7); ++i){
		POPCNT[i] = __builtin_popcount(i);
	}
	int n, m;
	cin >> n >> m;
	vector<int> broken(14);
	for(int i = 0; i < m; ++i){
		int d, p;
		cin >> d >> p;
		broken[d] |= (1 << p);
	}
	vector<ll> hms(100);
	for(int h = 0; h < 24; ++h){
		const int hc =
			POPCNT[TABLE[h % 10] & ~broken[9]] +
			POPCNT[TABLE[h / 10] & ~broken[8]];
		for(int m = 0; m < 60; ++m){
			const int mc =
				POPCNT[TABLE[m % 10] & ~broken[11]] +
				POPCNT[TABLE[m / 10] & ~broken[10]];
			for(int s = 0; s < 60; ++s){
				const int sc =
					POPCNT[TABLE[s % 10] & ~broken[13]] +
					POPCNT[TABLE[s / 10] & ~broken[12]];
				++hms[hc + mc + sc];
			}
		}
	}
	ll answer = 0;
	for(int y = 0; y < 10000; ++y){
		const int yc =
			POPCNT[TABLE[y % 10] & ~broken[3]] +
			POPCNT[TABLE[y / 10 % 10] & ~broken[2]] +
			POPCNT[TABLE[y / 100 % 10] & ~broken[1]] +
			POPCNT[TABLE[y / 1000] & ~broken[0]];
		for(int m = 1; m <= 12; ++m){
			int len = MONTH_TABLE[m];
			if(m == 2 && (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))){ ++len; }
			const int mc =
				POPCNT[TABLE[m % 10] & ~broken[5]] +
				POPCNT[TABLE[m / 10] & ~broken[4]];
			for(int d = 1; d <= len; ++d){
				const int dc =
					POPCNT[TABLE[d % 10] & ~broken[7]] +
					POPCNT[TABLE[d / 10] & ~broken[6]];
				const int sum = yc + mc + dc;
				if(sum <= n){ answer += hms[n - sum]; }
			}
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1200
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''
 





Measured memory_bytes: 10108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int dp[301];
  memset(dp,0,sizeof(dp));
  dp[0] = 1;
  vector<int> coin;
  for (int i=1; i*i<=289; ++i)
    coin.push_back(i*i);
  FOR(it, coin) {
    REP(i,300) {
      if (i+*it>300) break;
      dp[i+*it] += dp[i];
    }
  }
  int n;
  while(cin >> n, n)
    cout << dp[n] << endl;
}

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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

template <typename T>
void printV(vector<T> &v, const string &sep = " ") {
	using namespace std;
	if (v.empty()) return;
	cout << v[0];
	for(int i = 1;  i < v.size(); ++i) {
		cout << " " << v[i];
	}
	cout << endl;
	return;
}

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

	int r = read();
	int c = read();
	vector<vector<int> > field(r + 1, vector<int>(c + 1));
	int corner_sum = 0;
	REP(i, r) {
		int sum = 0;
		REP(j, c) {
			field[i][j] = read();
			sum += field[i][j];
		}
		field[i][c] = sum;
		corner_sum += sum;
	}
	field[r][c] = corner_sum;
	REP(j, c) {
		int sum = 0;
		REP(i, r) {
			sum += field[i][j];
		}
		field[r][j] = sum;
	}

	REP(i, r + 1) {
		printV(field[i]);
	}
	
	return 0;
}



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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  vector<int> A(3);
  REP(i,3) cin >> A[i];
  sort(ALL(A));
  string res = "YES";
  vector<int> B = {5, 5, 7};
  REP(i,3) if(A[i] != B[i]) res = "NO";
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	int64 nn, ans = 1;
	cin >> nn >> ss;
	for(int64 ii = 1;ii < nn;ii++)
	{
		if(ss[ii] != ss[ii - 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main() {
int N,i;
cin>>N;
double x[N+1];
string u[N];
for(i=0;i<N;i++){
  cin>>x[i]>>u[i];
}
for(i=0;i<N;i++){
  if(u[i]=="JPY") x[i]=x[i];
    else x[i]=x[i]*380000;
}
for(i=0;i<N;i++){
 x[i+1]+=x[i];
}
cout<<x[N];
}


Measured memory_bytes: 256
S=str(input())
if S[1]=="R":
  if S[2]=="R" and S[0]=="R":
    print(3)
  else:
    if S[0]=="R":
      print(2)
    elif S[2]=="R":
      print(2)
    else:
      print(1)
else:
  if S[2]=="R" or S[0]=="R":
    print(1)
  else:
    print(0)

Measured memory_bytes: 9048
#include <iostream>
#include <vector>
#include <queue>
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int BLACK = 1;

int n;
std::vector<std::pair<int, int> > adj[MAX];

void dijkstra() {
  std::priority_queue<std::pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0; i<n; ++i) {
    color[i] = WHITE;
    d[i] = INFTY;
  }

  d[0] = 0;
  PQ.push(std::make_pair(0, 0));

  while(!PQ.empty()) {
    std::pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second; // ..? これは重みでは?

    color[u] = BLACK;

    if(d[u] < f.first * (-1)) continue;

    for(int j=0; j<adj[u].size(); ++j) {
      int v = adj[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(std::make_pair(d[v] * (-1), v));
      }
    }
  }

  for(int i=0; i<n; ++i) {
    std::cout << i << " " << d[i] << std::endl;
  }

}


int main() {
  int k, u, v, c;
  std::cin >> n;

  for(int i=0; i<n; ++i) {
    std::cin >> u >> k;
    for(int j=0; j<k; ++j) {
      std::cin >> v >> c;
      adj[u].push_back(std::make_pair(v, c));
    }
  }

  dijkstra();
}


Measured memory_bytes: 7980
H, W, K = map(int, input().split())

S = [list(map(int, input())) for _ in range(H)]

C = [[0 for w in range(W)] for h in range(H)] #各行のw列目までに1が何個あるか

#print(S)
for h in range(H):
  for w in range(W):
    #print(h,w)
    C[h][w] = C[h][w-1] + S[h][w]

#print(C)
def settify(l):
  set_label = set()
  i = 0
  while l > 0:
    if l % 2 == 1:
      set_label.add(i)
    l //= 2
    i += 1
  return set_label
    
def set_label(s):
  tmp = 0
  for i in s:
    tmp += 2**i
  return tmp

def sum_set(s, w):
  s_list = list(s)
  s_list.sort()
  s_list.append(H-1)
  tmp = 0
  it = 0
  ans_list = []
  for h in range(H):
    tmp += C[h][w]
    #print(w, tmp)
    if h == s_list[it]:
      ans_list.append(tmp)
      tmp = 0
      it += 1
  return ans_list    
#print(sum_set(set(), 0), sum_set(set(), 1))
ans = 10**8
for l in range(2**(H-1)):
  s = settify(l)
  lt_prv = [0 for _ in range(len(s)+1)]
  lt_now = [0 for _ in range(len(s)+1)]
  lt_1minus = [0 for _ in range(len(s)+1)]
  tmp = len(s)
  w = 0
  w_prv = -1
  imp = False
  while w < W:
    lt_now = sum_set(s, w)
    flag = False
    for j in range(len(s)+1):
      if lt_now[j] - lt_prv[j] > K:
        flag = True
        break
    if flag:
      if w_prv == w-1:
        imp = True
      tmp += 1
      lt_prv = lt_1minus
      w_prv = w-1
    w += 1
    lt_1minus = lt_now
    if imp:
      break
    #print(s, w-1)
    #print(lt_prv, lt_1minus, lt_now)
  if not imp:
    ans = min(ans, tmp)
      
print(ans)
        
        
    
    
  
    
    





Measured memory_bytes: 74948
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
void swap(int *a,int *b){
	int t;
	t=(*a);
	(*a)=(*b);
	(*b)=t;
}
int selectionsort(int A[],int n){
	int min;
	int sw=0;
	int t;

	for(int i=0;i<n;i++){
		min=i;
		for(int j=i;j<n;j++){
			if(A[j]<A[min]) min=j;
		}
		swap(&A[i],&A[min]);
		if(i!=min) sw++;
	}
	for(int i=0;i<n;i++) {
		if(i>0) cout<<" ";
			cout<<A[i];
	}
	cout<<endl;
	return sw;
}

	
int main()
{
	int A[100];
	int N;
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i];

	cout<<selectionsort(A,N)<<endl;
	
	
	return 0;
}
	
	
	


Measured memory_bytes: 3092
#include <stdio.h>
#include <algorithm>
#include <vector>
#define MOD 1000000007

std::vector<long long int> V1,V2;
long long int x[200010];
int a,b;
long long int max()
{
	int k = b;
	for(int i=1;i<=a;i++)
	{
		if(x[i]>0) V1.push_back(x[i]);
		else if(x[i]<0) V2.push_back(x[i]);
	}
	std::sort(V1.begin(),V1.end());
	std::sort(V2.begin(),V2.end());
	
	int start1 = 0, start2 = 0, p,q;
	
	if(k<=V1.size()) start1 = V1.size()-k, q = 0;
	else q = k-V1.size(), start1 = 0;
	
	if(q%2==1) q++, start1++;
	
	for(int i=start1;i<(int)V1.size()-1;i+=2)
	{
		if(q+1>=V2.size()) break;
		
		long long int S = V1[i] * V1[i+1];
		long long int T = V2[q] * V2[q+1];
		if(S>=T)
		{
			long long int ans = 1;
			for(int j=i;j<V1.size();j++) ans *= V1[j], ans %= MOD;
			for(int j=0;j<q;j++)
			{
				ans *= V2[j], ans %= MOD;
				ans += MOD, ans %= MOD;
			}
			return ans;
		}
		q+=2;
	}
	
	if(k<=V2.size())
	{
		long long int ans = 1;
		if(k%2==0)
		{
			for(int j=0;j<k;j++)
			{
				ans *= V2[j], ans %= MOD;
				ans += MOD, ans %= MOD;
			}
			return ans;
		}
		else
		{
			for(int j=0;j<k-1;j++)
			{
				ans *= V2[j], ans %= MOD;
				ans += MOD, ans %= MOD;
			}
			ans *= V1[V1.size()-1], ans %= MOD;
			return ans;
		}
	}
	else
	{
		long long int ans = 1;
		if(V2.size()%2==0)
		{
			for(int j=0;j<V2.size();j++)
			{
				ans *= V2[j], ans %= MOD;
				ans += MOD, ans %= MOD;
			}
			
			int C = k-V2.size();
			for(int i=V1.size()-1 ; i>=(int)V1.size()-(int)(k-V2.size()) ; i--)
			{
				ans *= V1[i], ans %= MOD;
			}
			return ans;
		}
		else
		{
			for(int j=0;j<V2.size()-1;j++)
			{
				ans *= V2[j], ans %= MOD;
				ans += MOD, ans %= MOD;
			}
			for(int i=V1.size()-1;i>=(int)V1.size()-(int)(k-V2.size()+1);i--) ans *= V1[i], ans %= MOD;
			return ans;
		}
	}
}

long long int min()
{
	int k = b;
	int count = 0;
	long long int ans = 1;
	for(int i=1;i<=a;i++)
	{
		if(x[i]>0) V1.push_back(x[i]);
		else if(x[i]<0) V2.push_back(x[i]);
	}
	std::sort(V1.begin(),V1.end());
	std::sort(V2.begin(),V2.end());
	
	if(k<=V2.size())
	{
		for(int j=V2.size()-1;j>=(int)V2.size()-k;j--)
		{
			ans *= V2[j], ans %= MOD;
			ans += MOD, ans %= MOD;
		}
		return ans;
	}
	else
	{
		for(int j=0;j<V2.size();j++)
		{
			ans *= V2[j], ans %= MOD;
			ans += MOD, ans %= MOD;
		}
		
		for(int i=0;i<(k-V2.size());i++) ans *= V1[i], ans %= MOD;
		return ans;
	}
}

int main()
{
	int count1 = 0, count2 = 0, count3 = 0;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%lld",&x[i]);
	for(int i=1;i<=a;i++)
	{
		if(x[i]>0) count1++;
		else if(x[i]==0) count2++;
		else count3++;
	}
	if(count1+count3<b)
	{
		printf("0");
		return 0;
	}
	if(count2>0)
	{
		int m = 0>b-count1?0:b-count1;
		int M = b<count3?b:count3;
		
		if(m==M && m%2==1)
		{
			printf("0");
			return 0;
		}
		else
		{
			printf("%lld",max());
			return 0;
		}
	}
	else
	{
		int m = 0>b-count1?0:b-count1;
		int M = b<count3?b:count3;
		
		if(m==M && m%2==1)
		{
			printf("%lld",min());
			return 0;
		}
		else
		{
			printf("%lld",max());
			return 0;
		}
	}
}

Measured memory_bytes: 6408
import sys

n, *p = map(int, sys.stdin.read().split())


def main():
    cnt = 0
    for i in range(n):
        if p[i] != i + 1:
            cnt += 1
    
    if not cnt or cnt == 2:
        return 'YES'
    return 'NO'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;

ll n,nx,ny;
ll a,b;

int main(){
    scanf("%lld",&n);
    nx=ny=1;
    for(int i=1;i<=n;i++){
        ll t,x,y;
        scanf("%lld%lld",&a,&b);
        /*if(nx<a&&ny<b) nx=a,ny=b;
        else{*/
            t=max(1ll,max(nx/a,ny/b));
            x=a*t,y=b*t;
            while(x<nx||y<ny) x+=a,y+=b;
            nx=x,ny=y;
        //}
    }
    printf("%lld\n",nx+ny);
}


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

int main() {
    int N,seat = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int l,r;
        cin >> l >> r;
        seat += r - l + 1;
    }
    cout << seat << endl;
}


Measured memory_bytes: 256
n = int(input())
x = 0
y = 0
t = 0
ans = 'Yes'

for _ in range(n):
    ti, xi, yi = map(int, input().split())
    elapsed_time = ti - t
    if abs(x - xi) + abs(y - yi) > elapsed_time:
        ans = 'No'
        break
    dist_odd_even = (abs(x - xi) + abs(y - yi)) % 2
    time_odd_even = elapsed_time % 2
    if dist_odd_even != time_odd_even:
        ans = 'No'
        break
    x = xi
    y = yi
    t = ti

print(ans)

Measured memory_bytes: 3064
k = 26
D = gets.to_i
c = gets.split.map(&:to_i)
s = D.times.map { gets.split.map(&:to_i) }
D.times do |d|
  max_s = -1
  max_i = -1
  k.times do |i|
    if s[d][i] > max_s
      max_s = s[d][i]
      max_i = i
    end
  end
  puts max_i + 1
end


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;
int solve(int h,int w){
	int ret = INF;
	for(int i = 1;i <= h-1;i++){
		int one = i*w;
		int rest = (h-i)*w;
		{
			int two = (h-i)/2*w;
			int three = rest - two;
			int tmp  = max({one,two,three}) - min({one,two,three});
			// trace(i,one,two,three);
			ret = min(ret,tmp);
		}
		{
			int two = (h-i)*(w/2);
			int three = rest - two;
			int tmp  = max({one,two,three}) - min({one,two,three});
			ret = min(ret,tmp);
			// trace(i,one,two,three);
		}
		
		
	}
	return ret;	
}
signed main(){
	int h,w;cin >> h >> w;
	cout << min(solve(h,w),solve(w,h)) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <unordered_map>       // ヘッダファイルインクルード
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;


int main(){
    int n;
    cin >> n;
    string s[n]; 
    unordered_map<string, int> mp;
    long long ans=0;
    REP(i,n){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }

    for(auto p: mp){
        int val = p.second;
        ans += (long long)val*(val-1)/2;
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

string st;

int const nmax = 50;
int barby[1 + nmax];

int main() {

  long long n, bees, ans = 0;
  cin >> n >> bees;
  ans = 1;
  for(long long i = 1;i <= n;i *= bees){
    ans++;
  }
  cout << ans - 1;
  return 0;
}


Measured memory_bytes: 3600
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

aa = Array.new(A+1){|i| i*500}
bb = Array.new(B+1){|i| i*100}
cc = Array.new(C+1){|i| i*50}
puts aa.product(bb, cc).map{|v|v.inject(:+)}.grep(X).size


Measured memory_bytes: 16252