akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();

		String ans = "";

		for (int i = 0; i < n; i++) {
			ans += "ACL";
		}

		out(ans);

	}

	/*
	 * 以下メソッド集
	 */

	public static long[] kousokusoinnsuubunkaihairetsu(long n2) {
		long[] d = new long[(int) n2];
		for (int i = 0; i < n2; i++) {
			d[i] = i;
		}
		for (int i = 2; i * i < n2; i++) {
			for (int j = i * i; j < n2; j += i) {
				if (d[j] == j)
					d[j] = i;
			}

		}

		return d;
	}

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "2";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static long kaijo(long n) {

		debug(n);

		if (n == 0l || n == 1l) {
			return 1l;
		} else {
			return n * kaijo(n - 1l);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


Measured memory_bytes: 38648
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
 
 
 
int main()
{
    fast;
    lli n,m;
    cin>>n>>m;
    priority_queue<lli> pq;
    for(lli i=0; i<n; i++){
        lli x;
        cin>>x;
        pq.push(x);
    }
    for(lli i=0; i<m; i++){
        lli cur=pq.top();
        pq.pop();
        cur/=2;
        pq.push(cur);
    }
    lli ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int a,z;
  
  for (int i = 0; i < s.size(); i++) {
  	if (s[i] == 'A') {
    	a = i;
      break;
    }
  }
  
  for (int i = 0; i < s.size(); i++) {
  	if (s[i] == 'Z') {
    	z = i;
    }
  }
  
  cout << z - a + 1 << endl;
  
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,X,M;
    cin >> N >> X >> M;
    vector<int>used(100005);
    int old = X,j = 1;
    used[X] = true;
    while (true) {
        old = old*old%M;
        if(used[old]) {
            break;
        }
        used[old] = true;
        j++;
    }
    int sum = X;
    int now = X;
    old = X;
    for(int i = 2; i <= min(N,j); i++) {
        sum += old*old%M;
        old = old*old%M;
        now = old;
    }
    if(N <= j) {
        cout << sum << endl;
        return 0;
    }
    vector<int>s(100005);
    int cnt = 1;
    while (true) {
        old = old*old%M;
        s[cnt] = s[cnt-1]+old;
        if(old == now) {
            break;
        }
        cnt++;
    }
    cout << sum+(N-min(N,j))/cnt*s[cnt]+s[(N-min(N,j))%cnt] << endl;
}


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

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

	vector<char>s;

	if (n == 0) {
		cout << '0' << endl;
		return 0;
	}
	while (n != 0) {
		if (n % 2 != 0) {
			s.insert(s.begin(), '1');
			n--;
		}
		else {
			s.insert(s.begin(), '0');
		}
		n /= -2;
	}
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

// auto mod int

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint fun(int n) {
  if(n==0) return 1;
  mint x = fun(n/2);
  x*=x;
  if(n%2==1) x*=2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = fun(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}


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

int main(void){
  int a,b;
  cin>>a>>b;
  long long result1,result2;
  result1=0;
  result2=0;
  for(int i=0;i<b;i++){
    result1+=a*pow(10,i);
  }
  for(int i=0;i<a;i++){
    result2+=b*pow(10,i);
  }
  string s1=to_string(result1);
  string s2=to_string(result2);
  if(s1<s2) cout<<s1<<endl;
  else cout<<s2<<endl;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    const int MAX_VALUE = 100 * 1e3 + 1;
    const long INF = 1e15;
    vector<long> dp(MAX_VALUE, INF);
    dp[0] = 0;
    int answer = 0;
    for (int i = 0; i < N; i++) {
        for (int j = MAX_VALUE - 1; j >= v[i]; j--) {
            if (dp[j - v[i]] + w[i] <= W) {
                dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
                answer = max(answer, j);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>

int main()
{
	int N;
	std::cin >> N;
	std::set<std::string> s;
	for(int i = 0; i < N; i++)
	{
		std::string tmp;
		std::cin >> tmp;
		s.insert(tmp);
	}
	std::cout << s.size();
}

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

int main() {
	int n;
	cin >> n;
	vector<int>l(n);
	for (int i = 0; i < n; i++)cin >> l.at(i);
	sort(l.begin(), l.end());
	ll ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			int a = l.at(i);
			int b = l.at(j);
			int x = lower_bound(l.begin(),l.end(), a + b) - l.begin();
			ans += x - j - 1;
			//cout << a << " " << b << " " << x << " " << x - j << endl;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 384
#include <stdio.h>
int main() {
	int i;

	int N;
	int A[100000];
	int B[100000];

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		B[A[i] - 1] = i + 1;
	}

	for (i = 0; i < N; i++) {
		if (i != 0) printf(" ");
		printf("%d", B[i]);
	}

	return 0;
}

Measured memory_bytes: 1536
N, m = map(int, input().split())
k = []
s = []
for i in range(m):
    KS = list(map(int, input().split()))
    k.append(KS[0])
    s.append(KS[1:])
p = list(map(int, input().split()))

count = 0
for l in range(2**N):
    flag = 1
    for t in range(m):
        sigma = 0
        for j in range(k[t]):
            sigma += l // (2**(s[t][j]-1))
        if sigma % 2 !=p[t]:
            flag =0
            break
    count += flag
print(count)

Measured memory_bytes: 3064
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int N = int.Parse(ReadLine());
         if(N%1000 == 0)WriteLine(N%1000);
         else WriteLine(1000-N%1000);
      }
   }
}

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

using namespace std;

int main(){

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

    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < 4; i++)
        if(s[i]=='+')++ans;
        else --ans;
    cout << ans << '\n';

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC071
{
    static class DebiousDocument
    {
        class SlicedString
        {
            int[] chars = new int[26];
            public SlicedString(string str)
            {
                foreach (var c in str)
                    chars[c - 'a'] += 1;
            }
            public static implicit operator SlicedString(string str)
            {
                return new SlicedString(str);
            }
            private SlicedString(int[] cs)
            {
                chars = cs;
            }
            public static SlicedString operator|(SlicedString a, SlicedString b)
            {
                var cs = new int[26];
                for (var i = 0; i < 26; ++i)
                    cs[i] = (a.chars[i] < b.chars[i]) ? a.chars[i] : b.chars[i];
                return new SlicedString(cs);
            }
            static string Repeat(char c, int t)
            {
                var sb = new StringBuilder();
                for (var i = 0; i < t; ++i)
                    sb.Append(c);
                return sb.ToString();
            }
            private int Chars(char c)
            {
                return chars[c - 'a'];
            }
            public override string ToString()
            {
                var sb = new StringBuilder();
                foreach (var c in "abcdefghijklmnopqrstuvwxyz")
                    sb.Append(Repeat(c, Chars(c)));
                return sb.ToString();
            }
        }
        static int[] To(this int from, int t)
        {
            var res = new int[t - from + 1];
            for (;from <= t; ++from)
                res[t - from] = from;
            return res;
        }
        static T FoldLeft<T>(this T[] vec, Func<T, T, T> func)
        {
            var init = vec[0];
            for (var i = 1; i < vec.Length; ++i)
                init = func(init, vec[i]);
            return init;
        }
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            WriteLine(1.To(n).Select(i => new SlicedString(ReadLine().Trim())).ToArray().FoldLeft((a, b) => { return a | b; }).ToString());
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 998244353
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define maxx 200002
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    int sx,sy,tx,ty;
    string s;
    cin>>sx>>sy>>tx>>ty;
    REP(i,0,ty-sy) s+='U';
    REP(i,0,tx-sx) s+='R';
    REP(i,0,ty-sy) s+='D';
    REP(i,0,tx-sx) s+='L';
    s+='L';
    REP(i,0,ty-sy+1) s+='U';
    REP(i,0,tx-sx+1) s+='R';
    s+='D';s+='R';
    REP(i,0,ty-sy+1) s+='D';
    REP(i,0,tx-sx+1) s+='L';
    s+='U';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;

char p[511][511];
int n;

bool h[511];
int c[511];
int ans;
int ans0;
int main()
{
    int i,j,k;
    
    scanf("%d",&n);
    
    memset(c,0,sizeof(c));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf(" %c",&p[i][j]);
            if(p[i][j]=='.')
            {
                c[i]++;
            }
        }
    }
    
    
    memset(h,0,sizeof(h));
    ans=0;
    ans0=9999999;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(p[j][i]=='.')
            {
                ans++;
                break;
            }
        }
    }
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(p[i][j]=='#')
            {
                int tmp=c[j];
                ans0=min(ans+tmp,ans0);
            }
            else if(c[i]<n)
            {
                int tmp=c[j];
                if(p[j][j]=='#')
                {
                    tmp+=2;
                }
                else
                {
                    tmp++;
                }
                ans0=min(ans+tmp,ans0);
            }
        }
    }
    
    if(ans0==9999999)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<ans0<<endl;
    }
    
    
    
    return 0;
}



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

using namespace std;

const int MAXN = 1005;
const int oo = 1000000007;

struct Edge {
    int u, v;
    bool avail;
};

int n, m, par[MAXN];
bool visited[MAXN];
vector<Edge> edges;
vector<int> adj[MAXN];

void dfs(int u) {
    visited[u] = true;
    for(int i : adj[u]) {
        int v = edges[i].u + edges[i].v - u;
        if (edges[i].avail && !visited[v]) {
            par[v] = u;
            dfs(v);
        }
    }
}

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

    for(int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;

        edges.push_back({u, v, true});
        adj[u].push_back(i);
    }

    vector<int> ans;
    int minCyc = oo;

    for(int i = 0; i < m; ++i) {
        edges[i].avail = false;

        fill(visited, visited+n, false);
        fill(par, par+n, -1);

        int s = edges[i].v, t = edges[i].u;

        dfs(s);
        if (visited[t]) {
//            printf("%d %d\n", s, t);

            vector<int> cyc;
            for(int v = t; v != s; v = par[v])
                cyc.push_back(v);
            cyc.push_back(s);

            if (cyc.size() < minCyc) {
                minCyc = cyc.size();
                ans = cyc;
            }
        }

        edges[i].avail = true;
    }

    if (minCyc != oo) {
        printf("%d\n", ans.size());
        for(int u: ans)
            printf("%d\n", u+1);
    } else
        puts("-1");

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
 
int main(void){
  int N,i,j,sum=0,min=1000000;
  int x[105];
  scanf("%d\n",&N );
  for(i=0;i<N;i++){
    scanf("%d",&x[i] );
  }
  for(i=1;i<101;i++){
    for(j=0;j<N;j++){
      sum += pow(x[j]-i ,2);
    }
    if(sum < min){
      min = sum;
    }
    sum = 0;
  }
  printf("%d\n",min );
  return 0;
}

Measured memory_bytes: 128
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

count = 0

for i in range(n):
  a = list(map(int, input().split()))
  sum = 0
  for j, xj in enumerate(a):
    sum += a[j] * b[j]
   
  if sum + c > 0:
    count += 1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>
int main() {
	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	int tmp;
	tmp = x;
	x = y;
	y = tmp;
	tmp = x;
	x = z;
	z = tmp;
	printf("%d %d %d\n", x, y, z);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//まあ大丈夫だと思うが集合の数はsetに各ノードの根を入れてその大きさ見れば良い
//各グループの要素数uf.size[uf.find(1)]みたいな感じでfind経由忘れずに
//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> size;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			size.push_back(1);
		}
	}
 
	int find(int x) {
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			size[y]+=size[x];
		}else{
			par[y]=x;
			size[x]+=size[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
	}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,k;
	cin>>n>>m>>k;
	UnionFind uf1(n+10),uf2(n+10);
	vector<set<int>> g1(n),g2(n);
	rep(i,n) g1[i].insert(i);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g1[a].insert(b);
		g1[b].insert(a);
		uf1.unite(a,b);
		uf2.unite(a,b);
	}
	rep(i,k){
		int c,d;
		cin>>c>>d;
		c--,d--;
		if(uf1.same(c,d)){
			g1[c].insert(d);
			g1[d].insert(c);
		}
		uf2.unite(c,d);
	}
	rep(i,n){
		cout<<uf1.size[uf1.find(i)]-g1[i].size()<<endl;
	}
}

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

int main() {
  int r;
  cin >> r;
  double ans = r*2*acos(-1);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        cout << s[s.size()-i-1];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
int n,k,x,y;
cin>>n>>k>>x>>y;
asas;
rop(i,n){
if(i<=k)ans+=x;
else ans+=y;
}
cout<<ans<<rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MaxNUM 100

int main( void )
{
    char tmp;
    char i,j,k = 0;
    unsigned char Num = 0;
    
    unsigned short Array[MaxNUM];
    unsigned short v = 0;

    // ??\??? 1?????????????????°?????????
    // ????????????????????\????????§??£?¶???????
    while( (tmp = getchar()) != '\n' )
    {
        Num = (Num * 10) + (tmp - '0'); // ??????????????°???????????????????¶?????????????
    };
    
    // ??\??? 2??????????????????????????????????????????
    for(k=0; k<Num; k++ )
    {
        // ??????????????????
        Array[k]=0;
    
        do{
            tmp = getchar();
            printf("%c",tmp);
            
            if(tmp == '\n') //???????????????????????????
            {
                break;
            }
            
            if( tmp != ' ' )
            {
                Array[k] = Array[k] * 10 + (tmp - '0');
            }
        }while(tmp != ' ' && tmp != '\n'); // ???????????£???????¬???????????????????
    }

    // ?????????
    for( i=1; i<Num; i++ )
    {
        v = Array[i];
        j = i - 1;
    
        // ??????????????????????????§????????¨??????1??????????????¨??\????????????
        while( j >= 0 && Array[j] > v )
        {
            Array[j+1] = Array[j];
            Array[j] = v;
            j--;
        }
    
        // ???????????????????????????????????????????????????????????????
        for(k=0; k<Num; k++ )
        {
            printf("%d",Array[k]);
            if( k == Num-1 )
            {
               printf("\n");    // ???????????????
            }
            else
            {
               printf(" ");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,w,i,j,a,b;
    cin>>n>>w;
    vector<pair<int,long long int> > v;
    for(i=0;i<n;++i)
    {
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    long long int dp[n+1][w+1]={};

    for(i=1;i<=n;++i)
    {
        for(j=1;j<=w;j++)
        {
            if(j>=v[i-1].first)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1].first]+v[i-1].second);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];

}


Measured memory_bytes: 79232
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
    long[] nums = new long[n];
    long answer = 0;
    for(int i = 0; i < n; i++) nums[i] = long.Parse(Console.ReadLine());
    
		for(int i = 0; i < n; i++)
    {
      answer += nums[i]/2;//2の倍数個とる
      nums[i] -= nums[i]/2*2;
      if(nums[i] == 1 && i+1 < n)
      {
        if(nums[i+1] > 0)
        {
          nums[i+1]--;
          answer++;
        }
      }
    }
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 17336
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		char[] a = sc.next().toCharArray();
		Arrays.sort(a);
		if(a[0] == 'a' && a[1] == 'b' && a[2] == 'c') ou.println("Yes");
		else ou.println("No");
		ou.flush();
	}
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int H, N;
    int su = 0;
    cin >> H >> N;
    rep(i, N){
        int A; cin >> A;
        su += A;
        if(su>=H){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int n;
int a[100000];
int x[20][20];
int y[20][20];

int jud(int hypo) {
	int conf[20] = {}; // 0 = 不親切, 1 = 正直 
	for (int i = 0; i < n; i++) if (hypo&(1<<i)) conf[i] = 1;

	for (int i = 0; i < n; i++) {
		if (conf[i]) {
			// 以下、i番目の人の発言が正しいとする
			for (int j = 0; j < a[i]; j++) {
				// 以下、i番目の人のj個目の発言について
				if (conf[x[i][j]-1] != y[i][j]) return 0;
			}
		}
	}
	return 1;
}

int bitcnt(int n) {
	int cnt = 0;
	while (n) {
		if (n&1) cnt++;
		n >>= 1;
	}
	return cnt;
}

int main()
{
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		rep(j,a[i]) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < (1<<n); i++) {
		if (jud(i)) {
			ans = max(ans,bitcnt(i));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

w, h, n = imap()
x = [0]*n; y = [0]*n; a = [0]*n
for i in range(n):
    x[i], y[i], a[i] = imap()

xr = yu = 0
xl = w; yd = h
for i in range(n):
    if a[i]==1: xr = max(xr, x[i])
    if a[i]==2: xl = min(xl, x[i])
    if a[i]==3: yu = max(yu, y[i])
    if a[i]==4: yd = min(yd, y[i])
sx = min(w, xr+w-xl)
sy = min(h, yu+h-yd)
print(h*w-(sx*h+sy*w-sx*sy))

Measured memory_bytes: 12492
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int main(){
    for(;;){
        int outs[101];
        for(int i=0;i<=100;i++){
            outs[i]=0;
        }
        for(;;){
            int a,b;
            if(scanf("%d%d",&a,&b)==-1) return 0;
            if(a==0&&b==0) break;
            outs[a]++;
            outs[b]++;
        }
        bool is=true;
        for(int i=3;i<=100;i++){
            if(outs[i]%2!=0) is=false;
        }
        if(is&&outs[1]%2==1&&outs[2]%2==1) printf("OK\n");
        else printf("NG\n");
    }
}

Measured memory_bytes: 0
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab = sorted(ab, key=lambda x:x[1])
count = 0

del_num = 0
for i in range(M):
  if ab[i][0] >= del_num:
    count += 1
    del_num = ab[i][1]
print(count)

Measured memory_bytes: 65368
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  998244353
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  ll ans=1;
  vector<ll> d(n);
  rep(i,n) cin >> d[i];
  vector<ll> dist(n);
  rep(i,n) dist[i]=0;

  rep(i,n){
    int x=d[i];
    dist[x]++;
    if(i!=0 && x==0){
      cout << "0" << endl;
      return 0;
    }
  }

  for(ll i=1; i<n; i++){
    int eda=dist[i-1],kyori=dist[i];
    rep(j,kyori) {
      ans*=eda;
      ans%=MOD;
    }
  }
  cout << ans%MOD << endl;
  return 0;
}


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

struct point{
	double x,y;
}; 

void koch(int n,struct point a,struct point b)
{
	struct point s,t,u;
	double th=M_PI*60.0/180.0;
	if(n==0)
	{
		return;
	}
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	t.x=(1.0*a.x+2.0*b.x)/3.0;
	t.y=(1.0*a.y+2.0*b.y)/3.0;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y); 
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y); 
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y); 
	koch(n-1,t,b);
}

int main()
{
	struct point a,b;
	int n;
	scanf("%d",&n);
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}



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

int main() {
	int N, T;
	cin >> N >> T;
	int t[N];
	for (int i = 0; i < N; ++i) cin >> t[i];

	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		if (t[i] - t[i - 1] <= T) ans += t[i] - t[i - 1];
		else ans += T;
	}
	
	ans += T;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4336
fn read<T: std::str::FromStr>() -> T {
    let mut buff = String::new();
    std::io::stdin().read_line(&mut buff).ok();
    buff.trim().parse().ok().unwrap()
}

fn main() {
    let mut x = read::<i32>();
    let mut ans = vec![];
    ans.push((x % 60).to_string());
    x = x / 60;
    ans.push((x % 60).to_string());
    x = x / 60;
    ans.push(x.to_string());
    ans.reverse();
    
    println!("{}", ans.join(":"));
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int x;cin >> x;
    cout << 10 - x/200 << endl;
}

Measured memory_bytes: 3564
N = int(input())
F = [list(map(str,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
INF = 10**12

ans = -INF
for i in range(1,2**10):
    cnt = [0]*N
    res = 0
    bs = format(i,"b")
    bs = bs.zfill(10)
    for j in range(N):
        fs = "".join(F[j])
        for k in range(10):
            if fs[k] == "1" and bs[k] == "1":
                cnt[j] += 1
    for l in range(N):
        res += P[l][cnt[l]]
    if res > ans:
        ans = res
print(ans)

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int h,w,n;
	while(cin>>h>>w>>n,h||w||n){
		vvint vv;
		initvv(vv,h,w);
		vvint dp=vv;
		rep(i,h){
			rep(j,w){
				cin>>vv[i][j];
				dp[i][j]=0;
			}
		}
		dp[0][0]=n-1;
		rep(i,h){
			rep(j,w){
				int a=dp[i][j]/2;
				int b=dp[i][j]-a;
				if(vv[i][j]){
					if(j+1<w) dp[i][j+1]+=b;
					if(i+1<h) dp[i+1][j]+=a;
				}
				else{
					if(j+1<w) dp[i][j+1]+=a;
					if(i+1<h) dp[i+1][j]+=b;
				}
			}
		}
		rep(i,h){
			rep(j,w){
				if(dp[i][j]%2) vv[i][j]=1-vv[i][j];
			}
		}
		int x=0,y=0;
		while(1){
			if(y==h||x==w){
				cout<<y+1<<" "<<x+1<<endl;
				break;
			}
			if(vv[y][x]){
				x++;
			}
			else{
				y++;
			}
		}	
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a+b<x){
        cout << "NO";
    } else if (a>x) {
        cout << "NO";
    } else {
        cout << "YES";
    }
    return 0;
}


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

int main() {
	int s, h, m, sec;
	cin >> s;
	h = s / 3600;
	m = (s - h * 3600) / 60;
	sec = s - h * 3600 - m * 60;
	cout << h << ":" << m << ":" << sec << "\n";
		return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
	return modpow(a, mod - 2, mod);
}
void solve()
{
	COMinit();
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans = modpow(2, n, M) - 1;
	ans %= M;
	ll mid = 1;
	FOR(i, 0, a)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;

	mid = 1;
	FOR(i, 0, b)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;
	while (ans < 0)
	{
		ans += M;
	}
	cout << ans % M << endl;
}

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


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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    deque<int> deq;
    rep(i,n){
        if(i%2==0){
            deq.push_back(a[i]);
        }else{
            deq.push_front(a[i]);
        }
    }
    if(n%2==1){
        reverse(deq.begin(),deq.end());
    }
    for(auto t : deq) cout << t << " ";
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

double dist(pair<double, double> p, pair<double, double> q){
    return sqrt(pow(p.first - q.first, 2) + pow(p.second - q.second, 2));
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int n;
    cin >> n;
    vector<pair<double, double>> xy(n);
    FOR(i, n)
        cin >> xy[i].first >> xy[i].second;

    vector<int> p(n);
    iota(p.begin(), p.end(), 0);

    double sum = 0;
    double cnt = 0;
    do{
        double len = 0;
        FOR1(i, n-1)
            len += dist(xy[p[i-1]], xy[p[i]]);

        sum += len;
        cnt += 1;
    }while(next_permutation(p.begin(), p.end()));
    cout << sum / cnt << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll x, ll  y) 
{ 
	ll m=md;
   	ll ans=1;
    while (y > 0) 
    {
        if (y & 1)
            ans = (ans * x) % m;
        x = (x * x) % m;
        y >>= 1;
    }
    return ans;
} 

int main()
{
	IOS
	


	ll a,b;
	cin>>a>>b;
	cout<<max(2*a-1,max(2*b-1,a+b))<<endl;


    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if (N-i)%i == 0:
        m = (N-i)//i
        if m > 0:
        	if N//m == N%m:
        		ans += (N-i)//i
print(ans)

Measured memory_bytes: 3060
def is_palindrome str
  str == str.reverse
end
 
def solve s, t
  
  return  0 if is_palindrome(s) 
  return -1 unless is_palindrome(t)
  
  sl = s.length
  tl = t.length
  
  o = (tl+1)/2 - 1
  i = j = k = l = m = cnt = 0
  
  r = s.reverse
  
  loop do
      
    while s[i] == 'x' do
      i+=1; k+=1;
    end
    
    while r[j] == 'x' do
      j+=1; l+=1;
    end
    
    cnt += ( k - l ).abs
    
    k = l = 0

    break if m == o
    
    i += 1; j += 1; m += 1
  end
  
  return cnt
end
 
s = gets.chomp
t = s.gsub("x","")
 
puts solve s, t

Measured memory_bytes: 2300
import sys
import math
import bisect

def solve(A, m):
    n = len(A)
    min_val = 10 ** 18
    A.sort()
    for i in range(n):
        if i + m <= n:
            val = A[i+m-1] - A[i]
            min_val = min(min_val, val)
    return min_val

def main():
    n, m = map(int, input().split())
    A = []
    for i in range(n):
        A.append(int(input()))
    print(solve(A, m))

if __name__ == "__main__":
    main()


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < K; i++) {
		res += A[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 3624
int main(){
  int th,ta,ah,aa;
  scanf("%d%d%d%d",&th,&ta,&ah,&aa);
  int tc,ac;
  tc=(ah%ta==0)?ah/ta:ah/ta+1;
  ac=(th%aa==0)?th/aa:th/aa+1;
  if (tc<=ac) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
# define pi           3.14159265358979323846

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    double a,b;
    int h,m;
    cin >> a >> b >> h >> m;
    h *= 60;
    m += h;
    int minuti = m * 6;
    minuti %= 360;
    double sati = m;
    sati /= 2;
    while(sati > 360)sati -= 360;
    double ugao = minuti - sati;
    if(ugao < 0)ugao = abs(ugao);
    //cout << fixed << setprecision(10) << ugao << endl;
    double pravi = ugao * pi;
    pravi /= 180;
    double res = a*a + b*b - 2 * cos(pravi)*a*b;
    res = sqrt(res);
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
   using namespace std;
   int main()
   {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int n;
   cin>>n;
   int res=n%1000;
   if(res==0)
   cout<<res;
   else
   cout<<(1000-res);
   

   return 0;
   }

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

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

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (u == s) {
        cout << a-1 << ' ' << b << endl;
    } else {
        cout << a << ' ' << b-1 << endl;
    }
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll mod=1e9+7;
using P=pair<int,int>;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll ans=0,sum=0;
    int r=0;
    for(int l=0;l<n;l++){
        while(r<n && (sum^a[r]) == (sum+a[r]))sum+=a[r++];
        ans+=r-l;
        if(l==r)r++;
        else sum^=a[l];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
from random import randint
from time import time
t1=time()

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
	r=list(map(int,input().split()))
	s.append(r)

def score(T):
	last=[0]*26
	happy=0
	for i in range(d):
		last[T[i]-1]=i+1
		happy+=s[i][T[i]-1]
		for j in range(26):
			happy-=(i+1-last[j])*c[j]
	return happy

t=[]
for i in range(d):
	t.append(i%26+1)

t2=time()
while t2-t1<1.85:
	tt=t.copy()
	tt[randint(1,d)-1]=randint(1,26)
	if score(tt)>score(t):
		t=tt.copy()
	t2=time()
for x in t:
	print(x)


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

int main() {
  string N;
  cin >> N;
  char a = N.at(0);
  char b = N.at(1);
  char c = N.at(2);
  char d = N.at(3);
  char e = N.at(4);
  char f = N.at(5);
  char g = N.at(6);
  char h = N.at(7);
  char i = N.at(8); 
  char j = N.at(9); 
  char k = N.at(10);
  char l = N.at(11);
 cout << a << b << c << d << " " << e << f << g << h << i << j << k << l << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll c=1;
	while(n--)
	{
		if(c<=k)
			c*=2;
		else
			c+=k;
	}
	cout<<c;
    return;
}

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

Measured memory_bytes: 3616
#include<iostream>

void insertionSort(int a[],int n)
{
  int i,j,v;
  for(i=0;i<n;++i){
    v=a[i];
    j=i-1;
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1]=v;
    }
  }
}

int main()
{
  int n,i,j;
  std::cin>>n;

  int a[n];
  for(i=0;i<n;++i){
    std::cin>>a[i];
  }

  for(j=1;j<=n;++j){
    insertionSort(a,j);
    for(i=0;i<n-1;++i){
      std::cout<<a[i]<<" ";
    }
    std::cout<<a[n-1]<<"\n";
  }


  return 0;
}



Measured memory_bytes: 3068
n, m = map(int, input().split())

table = [True for _ in range(m)]



ans = 0
for i in range(n):
    like = list(map(int , input().split()))[1:]
    # print(like)
    for j in range(m):
        if j+1 in like:
            pass
        else:
            table[j]=False
# print(table)
for is_liked in table:
    if is_liked:
        ans +=1
print(ans)




Measured memory_bytes: 3064