akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

template<typename T>
struct BIT2D {
	int H, W;
	vector<vector<T>> bit;
	BIT2D() :H(0), W(0) {}
	BIT2D(int _H, int _W) :H(_H), W(_W) { bit = vector<vector<T>>(H + 1, vector<T>(W + 1)); }
	void add1(int h, int w, T val) {
		for (int i = h; i <= H; i += i & -i) {
			for (int j = w; j <= W; j += j & -j) {
				bit[i][j] += val;
			}
		}
	}

	T sum1(int h, int w) {
		T res = 0;
		for (int i = h; i > 0; i -= i & -i) {
			for (int j = w; j > 0; j -= j & -j) {
				res += bit[i][j];
			}
		}
		return res;
	}
	//0-indexed
	void add(int h, int w, T val) { add1(h + 1, w + 1, val); }
	//0-indexed, [(sh,sw), (eh, ew))
	T sum(int sh, int sw, int eh, int ew) { return sum1(eh, ew) - sum1(eh, sw) - sum1(sh, ew) + sum1(sh, sw); }

};

struct Taiyaki {
	int t, h, w;
	Taiyaki(int _t, int _h, int _w) : t(_t), h(_h), w(_w) {}

	bool operator>(const Taiyaki& T) const {
		return t > T.t;
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int H, W, T, kkt; scanf("%d %d %d %d", &H, &W, &T, &kkt);
	BIT2D<int> bit1(H, W), bit2(H, W);
	priority_queue<Taiyaki, vector<Taiyaki>, greater<>> pq;
	while (kkt--) {
		int t, c; scanf("%d %d", &t, &c);
		while (!pq.empty() and pq.top().t <= t) {
			int h = pq.top().h;
			int w = pq.top().w;
			bit1.add(h, w, -1);
			bit2.add(h, w, 1);
			pq.pop();
		}
		if (c == 0) {
			int h, w; scanf("%d %d", &h, &w);
			h--; w--;
			bit1.add(h, w, 1);
			pq.emplace(t + T, h, w);
		}
		if (c == 1) {
			int h, w; scanf("%d %d", &h, &w);
			h--; w--;
			if (bit2.sum(h, w, h + 1, w + 1)) {
				bit2.add(h, w, -1);
			}
		}
		if (c == 2) {
			int sh, sw, eh, ew; scanf("%d %d %d %d", &sh, &sw, &eh, &ew);
			sh--; sw--;
			printf("%d %d\n", bit2.sum(sh, sw, eh, ew), bit1.sum(sh, sw, eh, ew));
		}
	}
	return 0;
}



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

int main() {
  int n, m; cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<string> b(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  
  bool ans;
  
  for (int r = 0; r <= n - m; r++) {
    for (int c = 0; c <= n - m; c++) {
      if (a[r][c] == b[0][0]) {
        ans = true;
        for (int rb = r; rb < r + m; rb++) {
          bool unfit = false;
          for (int cb = c; cb < c + m; cb++) {
            if (a[rb][cb] != b[rb - r][cb -c]) {
              unfit = true;
              break;
            }
          }
          if (unfit) {
            ans = false;
            break;
          }
        }
        if (ans) break;
      }
    }
    if (ans) break;
  }
  
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
coords = [list(map(int, input().split())) for _ in range(n)]

minx, maxx = 0, w
miny, maxy = 0, h

for x, y, a  in coords:
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    elif a == 4:
        maxy = min(maxy, y)

if minx > maxx or miny > maxy:
    print(0)
else:
    print((maxx-minx)*(maxy-miny))


Measured memory_bytes: 3064
/****************************
*  Developer : joshi08
*  Date  :  05-07-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a, lli n){ lli res = 1; while(n){ if(n%2==0){ a *= a; n /= 2; } else{ res *= a; n--; } } return res; }

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

	lli n,i,j,k,k1=0,k2=0,k3=0,k4=0;
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='A')
			k1++;
		else
		if(s[0]=='W')
			k2++;
		else
		if(s[0]=='T')
			k3++;
		if(s[0]=='R')
			k4++;
	}
	
	cout<<"AC x "<<k1<<"\nWA x "<<k2<<"\nTLE x "<<k3<<"\nRE x "<<k4;

    return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] && S[1] == S[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
student=[list(map(int,input().split())) for _ in range(n)]
checkpoint=[list(map(int,input().split())) for _ in range(m)]
ans=[0]*n

for i in range(n):
    distance=10**9
    index=0
    for j in range(m):
        if abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])<distance:
            distance=abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])
            index=j
    ans[i]=index+1
for i in range(n):
    print(ans[i])

Measured memory_bytes: 9116
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
	Scanner stdIn = new Scanner(System.in);
	
	short r = stdIn.nextShort();
	
	if (r < 1200) {
		System.out.println("ABC");
		return;
	}
	
	if (r < 2800) {
		System.out.println("ARC");
		return;
	}
	
	System.out.println("AGC");
	
	}

}

Measured memory_bytes: 21844
// Problem : 
// 			C - +/- Rectangle
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Grand Contest 016
// URL : https://atcoder.jp/contests/agc016/tasks/agc016_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int N, M, H, W;
int arr[505][505];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M >> H >> W;
	long long ans = N*M*3000LL;
	for(int i = 1; i<=N; i++){
		for(int j = 1; j<=M; j++){
			arr[i][j] = 3000;
		}
	}
	for(int i = H; i<=N; i+=H){
		for(int j = W; j<=M; j+=W){
			arr[i][j] = -(H*W-1)*3000LL-1;
			ans += -(H*W-1)*3000LL-1-3000;
		}
	}
	if(ans > 0){
		cout << "Yes\n";
		for(int i = 1; i<=N; i++){
			for(int j = 1; j<=M; j++){
				cout << arr[i][j] << " ";
			}
			cout << "\n";
		}
	}
	else{
		cout << "No\n";
	}
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int N;
    cin >> N;
    FOR(i, 1, 10){
        FOR(j, 1, 10){
            if(i * j == N){
                PRINT("Yes");
                return 0;
            }
        }
    } 
    PRINT("No");
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 998244353;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll num[1000100];

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> D(N);
    rep(i, N) {
        cin >> D[i];
        num[D[i]]++;
    }
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    if (N >= 2) {
        REP(i, 1, N) {
            if (D[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    ll ans = 1;
    ll ma = *max_element(all(D));
    REPS(i, 1, ma) {
        ans %= mod;
        ans *= modpow(num[i-1], num[i]);
    }
    cout << ans % mod << endl;

}

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

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

    vector<pair<ll,ll>>seq;

    for(int i=0; i<n; i++){
        int a,b; cin>>a>>b;
        seq.push_back(make_pair(a,b));
    }

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

    ll ans = 0;

    for(ll i=0; i<seq.size(); i++){
        ans += seq[i].second;
        if(ans >= k){
            cout<<seq[i].first<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;

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

	int count = 1;
	int current_loc = 0;

	for(int i = 0; i < n; ++i){
		int tmp;
		cin >> tmp;
		current_loc += tmp;
		if(current_loc <= x){
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    map<string, LLONG> str2NumMap;
    for (int i = 0; i < N; ++i)
    {
        string str; cin >> str;
        sort(str.begin(), str.end());
        ++str2NumMap[str];
    }
    LLONG ans = 0LL;
    for (const auto &kvp : str2NumMap)
    {
        LLONG num = kvp.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
function main()
    
    N = parse(Int, readline())
    answer = []
    
    if N % -2 == 0
        push!(answer, 0)
    else
        push!(answer, 1)
        N -= 1
    end

    i = 2
    while N != 0
        if N % 2^i == 0
            push!(answer, 0)
        else
            push!(answer, 1)
            N -= (-2)^(i-1)
        end
        i += 1
    end
    
    reverse!(answer)
    
    for i in answer
        print(i)
    end
    
end

main()

Measured memory_bytes: 165684
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	
	
		public static void main(String[] args) {
			Scanner scan=new Scanner(System.in);
			int a=scan.nextInt();
		    int b[]=new int[a];
          int max=0,sec=0;
          for(int i=0;i<a;i++){
            b[i]=scan.nextInt();
            if(max<b[i]){
              max=b[i];
            }else if(sec<b[i]){
              sec=b[i];
            }
            
          }
          for(int i=0;i<a;i++){
            if(b[i]==max)System.out.println(sec);
            else System.out.println(max);
          }
		}
}


Measured memory_bytes: 89332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, k;
	string s;
	cin >> n >> k >> s;
	
	
	s[k - 1] = tolower(s[k - 1]);
	
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

ans = 1
x = 0
while True:
    if a[x] == 2:
        print (ans)
        exit ()

    if ans > len(a):
        print (-1)
        exit ()

    x = a[x]-1
    ans += 1


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

int main() {	
	int n, b, f, r, v;
	int a[4][3][10] = {0};
	
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}

	for (int i=0; i<4; i++) {
		for (int j=0; j<3; j++) {
			for (int k=0; k<10; k++) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			for (int k=0; k<10; k++) {
				cout << "##";
			}
			cout << endl;			
		}
	}
	
	return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n;
    cin>>n;
    int a[n];

    int i, j;
    int min = INF;
    int max = 0;

    for(i=0; i<n; i++){
        cin>>a[i];
        if(a[i]<min){
            min = a[i];
        }
        if(a[i]>max){
            max = a[i];
        }
    }

    cout<<max-min<<endl;

    return 0;
}

Measured memory_bytes: 256
S = [input() for _ in range(3)]

i = [0,0,0]

t = 0  

while i[t]< len(S[t]):
    if S[t][i[t]] == "a":
        i[t] += 1
        t = 0
    elif S[t][i[t]] == "b":
        i[t] += 1 
        t = 1
    else:
        i[t] += 1
        t = 2
if t==0:
    print("A")
elif t==1:
    print("B")
else:
    print("C")


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int f1[][]=new int[3][10];
		int f2[][]=new int[3][10];
		int f3[][]=new int[3][10];
		int f4[][]=new int[3][10];

		for(int i=0;i<3;i++) {
			for(int j=0;j<10;j++) {
				f1[i][j]=0;
				f2[i][j]=0;
				f3[i][j]=0;
				f4[i][j]=0;
			}
		}
		for(int i=0;i<n;i++) {
			int buil=scan.nextInt();
			int f=scan.nextInt()-1;
			int r=scan.nextInt()-1;
			int num=scan.nextInt();
			switch(buil) {
				case 1:
					f1[f][r]+=num;
					break;
				case 2:
					f2[f][r]+=num;
					break;
				case 3:
					f3[f][r]+=num;
					break;
				case 4:
					f4[f][r]+=num;
					break;
				default:
					break;
			}

		}

		for(int k=0;k<4;k++) {
			for(int i=0;i<3;i++) {
				for(int j=0;j<10;j++) {
					if(k==0) System.out.print(" "+f1[i][j]);
					if(k==1) System.out.print(" "+f2[i][j]);
					if(k==2) System.out.print(" "+f3[i][j]);
					if(k==3) System.out.print(" "+f4[i][j]);
				}
				System.out.println();
			}
			if(k<3)System.out.println("####################");
		}

		scan.close();
	}

}


Measured memory_bytes: 29540
import java.util.Scanner;

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

        String str=sc.next();

        if (str.contains("A")&&str.contains("B")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;i++)cin >> l[i] >> r[i];
  vector<int> a(100009),b(100009);
  int cnt=0; a[0]=0;
  for(int i=1;i<Q;i++){
    if(S[i-1]=='A' && S[i]=='C'){cnt++;}
    a[i]=cnt;
  }
  cnt=0; b[N-1]=0;
  for(int i=N-2;i>=0;i--){
    if(S[i]=='A' && S[i+1]=='C'){cnt++;}
    b[i]=cnt;
  }
  //cout << cnt << endl;
  for(int i=0;i<Q;i++){
    int ans=cnt-a[l[i]-1]-b[r[i]-1];
    cout << max(ans,0) << endl;
  }
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int X;
	cin >> N >> X >> M;
	vector< int > last(M, -1);
	int A = X;
	int ans = A;
	int cycled = 0;
	last[A] = 0;

	rep(i, N - 1) {
		//cerr << i << endl;
		A = A * A % M;
		if (last[A] != -1 && !cycled) {
			int T = i + 1 - last[A];
			//cerr << T << endl;
			//cerr << A << endl;
			int S = 0;
			int A2 = A;
			S += A2;
			A2 = A2 * A2 % M;
			int last = A;
			while (A2 != A) {
				//cerr << S << endl;
				S += A2;
				last = A2;
				A2 = A2 * A2 % M;
			}
			ans += S * ((N - 1 - i) / T);
			i += (N - 1 - i) / T * T;
			i--;
			cycled = 1;
			A = last;
		} else
			ans += A;
		last[A] = i + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4048
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = sorted(a, reverse=True)
M1 = b[0]
M2 = b[1]
for i in range(n):
    if a[i] != M1:
        print(M1)
    else:
        print(M2)

Measured memory_bytes: 14112
from collections import deque

H, W = map(int, input().split())
m = [list(input()) for i in range(H)]
ans = 0
q = deque()

for h in range(H):
  for w in range(W):
    if m[h][w] == "#":
      q.append((h, w, 0))

while q:
  h, w, c = q.popleft()
  ans = max(ans, c)
  for dh, dw in ((-1, 0), (1, 0), (0, -1), (0, 1)):
    if 0 <= h+dh < H and 0 <= w+dw < W and m[h + dh][w + dw] == ".":
      m[h + dh][w + dw] = "#"
      q.append((h+dh, w+dw, c+1))

print(ans)

Measured memory_bytes: 161756
'''A - Still TBD
https://atcoder.jp/contests/abc119/tasks/abc119_a

>>> main("2019/04/30")
Heisei
>>> main("2019/11/01")
TBD'''

from datetime import datetime


def main(s):
    base_data = datetime(2019, 4, 30)
    year, month, day = map(int, s.split('/'))

    if datetime(year, month, day) <= base_data:
        print('Heisei')
    else:
        print('TBD')


if __name__ == "__main__":
    s = input()
    main(s)


Measured memory_bytes: 3312
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <cmath>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0)
    {
        cout << (A + B) / 2;
    }
    else
    {
        cout << "IMPOSSIBLE";
    }
    //
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	llint n, k;
	cin >> n >> k;
	llint s = (n / k);
	llint ans;
	if(k%2==1)ans= s * s * s;
	if (k % 2 == 0) {
		ans = pow((n/(k/2)) - (n / k), 3);
		ans += pow((n / k), 3);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
const int N=1048580,M=21;
int n,m,len,ans;
int f[M][N],g[M][N];
char s[N];
int main(){
	scanf("%d%d",&n,&m);
	For(i,0,n){
		scanf("%s",s);
		For(j,0,(1<<i)-1)
			f[i][j]=s[j]-'0';
	}
	For(i,1,n) For(j,0,(1<<i)-1){
		int b=(j>>(i-1))&1,r=0;
		for (;r<i&&((j>>(i-r-1))&1)==b;r++);
		g[i][j]=(r==i?-1:r);
	}
	For(i,0,n){
		For(j,1,n-i) For(k,0,(1<<(i+j))-1){
			f[i][k>>j]+=f[i+j][k];
			int t=g[j][k&((1<<j)-1)];
			if (t==-1) continue;
			f[i+j-t][((k>>j)<<(j-t))|(k&((1<<(j-t))-1))]+=f[i+j][k];
		}
		for (int j=(1<<i)-1;j>=0;j--)
			if (f[i][j]>=m){
				len=i; ans=j;
			}
	}
	for (int i=len-1;i>=0;i--)
		printf("%d",(ans>>i)&1);
}

Measured memory_bytes: 98688
A,B,Q = map(int, input().split())
inf = float("inf")
import sys
input = sys.stdin.readline
S = [-inf] + [ int(input()) for _ in range(A)] + [inf]
T = [-inf] + [ int(input()) for _ in range(B)] + [inf]
X = [ int(input()) for _ in range(Q)]

from bisect import bisect_left, bisect_right

for q in range(Q):
    x = X[q]

    i = bisect_left(S, x)
    j = bisect_left(T, x)
    left_S , right_S =  x - S[i-1], S[i] - x
    left_T , right_T =  x - T[j-1], T[j] - x

    res = min( 
            max(left_S, left_T),
            left_S + right_T + min(left_S, right_T),
            right_S + left_T + min(right_S, left_T),
            max(right_S, right_T) 
            )
    print(res)



Measured memory_bytes: 157416
N=int(input())
A=list(map(int,input().split()))
flag = 1
cnt=0
while flag:
  flag = 0
  for j in range(N-1,0,-1):
    if A[j] < A[j-1]:
      k=A[j]
      A[j]=A[j-1]
      A[j-1]=k
      flag = 1
      cnt+=1
print(*A)
print(cnt)


Measured memory_bytes: 5600
import math


A,B,H,M=map(int, input().split())


m=6*M
if m==0:
    m=360

h=30*H
h+=6*(M/12)
if h==0:
    h=360

kakudo=abs(h-m)
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(kakudo))))


Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
const ll p=998244353ll;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
int g[N],h[N],f[N],sz[N];
int find(int v){return f[v]?f[v]=find(f[v]):v;}
int a[N],b[N];
int main(){
	int n,i,j,x,y,v,u;ll s=0ll;
	scanf("%d",&n);
	for(i=1;i<=n;++i)sz[i]=1;
	for(i=1;i<=n;++i){
		scanf("%d%d",&x,&y);
		if(a[x]){
			v=find(a[x]);
			u=find(i);
			if(v!=u){f[u]=v;sz[v]+=sz[u];}
		}
		a[x]=i;
		if(b[y]){
			v=find(b[y]);
			u=find(i);
			if(v!=u){f[u]=v;sz[v]+=sz[u];}
		}
		b[y]=i;
	}
	for(i=1;i< N;++i)if(a[i])++g[find(a[i])];
	for(i=1;i< N;++i)if(b[i])++h[find(b[i])];
	for(i=1;i<=n;++i)s+=((ll)g[i])*h[i];
	printf("%lld",s-n);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  int h,w,k;cin>>h>>w>>k;
  int c[h][w],b=0,ans=0;
  char a;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      cin>>a;
      if(a=='#'){
        c[i][j]=1;
      }else{
        c[i][j]=0;
      }
    }
  }
  int d[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=c[i][j];
    }
  }
  for (int bith = 0; bith < (1<<h); ++bith){
    for(int bitw = 0; bitw < (1<<w); ++bitw){
      for(int i=0;i<h;i++){
        if (bith & (1<<i)) {
          for(int j=0;j<w;j++){
            c[i][j]=2;
          }
        }
      }
      for(int i=0;i<w;i++){
        if(bitw&(1<<i)){
          for(int j=0;j<h;j++){
            c[j][i]=2;
          }
        }
      }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(c[i][j]==1){b++;}
        }
      }
      if(b==k){ans++;}
      b=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      c[i][j]=d[i][j];
    }
  }
      
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
typedef long long ll;

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

    ll n, d;
    cin >> n >> d;

    ll res = 0;
    for(int i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;

        if(x*x + y*y <= d*d) ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5+5;

int n, h[N], dp[N];


int solve(int i)
{
    if(i == n-1)
        return 0;
    if(dp[i] != -1)   return dp[i];
    ll op1 = solve(i+1) + abs(h[i+1] - h[i]);
    ll op2 = op1;
    if(i + 2 < n)
        op2 = solve(i+2) + abs(h[i+2] - h[i]);
    return dp[i] = min(op1, op2);
}

int table()
{
    dp[0] = 0;
    for(int i=1; i<n; i++)
    {
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i-2>=0)  dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    return dp[n-1];
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> h[i];
    // memset(dp, -1, sizeof dp);
    cout << table();
    // cout << solve(0);


    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define FOR(i, a, b) for(long long i = a; i < b; ++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int a, b;
    while (cin >> a >> b) {
        printf("%d\n", a - b);
    }
    return 0;
}




Measured memory_bytes: 3152
def resolve():
    from functools import lru_cache
    n = int(input())

    @lru_cache(maxsize=1000)
    def attack(i):
        if i == 1:
            return 1
        else:
            return 1 + attack(i // 2) + attack(i // 2)

    print(attack(n))


resolve()


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 1; i <= n; i++)

int main() {
	int n, k;
	cin >> n >> k;
	long a[200001];
	re(i, n) cin >> a[i];
	re(i, n - k) {
		if (a[k + i] > a[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	


	return 0;
}

Measured memory_bytes: 5156
n,m,l=map(int, input().split())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for i in range(n):
    ci=[0]*l
    for k in range(l):
        for j in range(m):
            ci[k]+=a[i][j]*b[j][k]
    print(*ci)


Measured memory_bytes: 6572
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

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

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n - 1];

		for (int j = 0; j < n; j++) {
			a[j] = sc.nextInt();
		}

		for (int j = 0; j < n; j++) {
			b[j] = sc.nextInt();
		}

		for (int j = 0; j < n - 1; j++) {
			c[j] = sc.nextInt();
		}

		int result = Arrays.stream(b).sum();
		int before = -1;
		for (int x : a) {
			result += (before + 1 == x ? c[before - 1] : 0);
			before = x;
		}

		System.out.println(result);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
            return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
            }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
            }
        }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
        }

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define cas (tc)        cout << "Case " << tc << " :"
#define nl              cout << "\n";
#define pi              acos(-1)
#define mod             1000000007
#define inf             9999999999999999

const ll sz = 2e5;




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

        ll d, n;
        cin>>d>>n;
        vector<ll> x;
        l0(i,n){
            ll it;
            cin>>it;
            x.pb(it);
        }
        sorted(x);
        ll mx=0;
        for(ll i=1; i<n; i++){
            mx=max(mx, x[i]-x[i-1]);
        }
        mx=max(mx, x[0]-x[n-1]+d);

        cout<<d-mx;
        nl
          
    return 0;
}

Measured memory_bytes: 5332
///A man can't be always right.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define pb push_back
#define ppb pop_back
#define pi 3.14159265358979323846264338327950288419716939937510
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 200010
using namespace std;

int main()
{
    RUN_FAST;
    string s1, s2;
    int l, cnt=0, i;
    cin >> s1 >> s2;
    l=s1.size();
    for (i=0; i<l; i++) {
        if (s1[i]!=s2[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3812
#include <iostream>

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

using namespace std;

int h, w;
char m[100][100];
int m2[100][100] = {0};
void exp(int x, int y, char f) {
  if(x < 0 || w <= x || y < 0 || h <= y) return;
  if(m[x][y] != f || m2[x][y] == 1) return;

  m2[x][y] = 1;
  exp(x-1, y, f);
  exp(x+1, y, f);
  exp(x, y-1, f);
  exp(x, y+1, f);

  return;
}

int main() {
  while(cin >> h >> w, h) {
    rep(i, 0, h) {
      rep(j, 0, w) {
	cin >> m[j][i];
	m2[j][i] = 0;
      }
    }

    int ans = 0;
    rep(i, 0, h) {
      rep(j, 0, w) {
	if(m2[j][i] == 0) {
	  exp(j, i, m[j][i]);	  
	  ans ++;
	}
      }
    }

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

Measured memory_bytes: 1512
let main x =
  let x' = float_of_int x in
  let rec loop i y =
    if x' <= y then
      print_int i
    else
      loop (i + 1) (float_of_int (int_of_float (y *. 1.01)))
  in
  loop 0 (float_of_int 100);;

Scanf.sscanf (read_line ()) "%d" (fun x ->
    main x
);;

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//
int k[(int)pow(10,6) + 1] = {};
int main(){
    int n,max_a = -1;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        k[a]++;
        if(max_a < a)
            max_a = a;
    }
    int max = -1;
    
    for(int i = 1; i <= max_a+1; ++i){
        int a = k[i-1] + k[i] + k[i+1];
        if(max < a)
            max = a;
    }
    cout << max << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<set>
#include<tuple>
#include<vector>

using namespace std;

typedef pair<char,char> PII;
typedef tuple<set<PII>,set<PII>,set<PII> > T;

bool neighbor(const set<PII> &s,PII p){
  for(int i=0;i<4;i++){
    static int d[]={0,1,0,-1,0};
    auto pp=PII(p.first+d[i],p.second+d[i+1]);
    if(s.count(pp))return true;
  }
  return false;
}

void set_bit(__int128 &i,PII e){
  i|=__int128(1)<<e.first*10+e.second;
}

__int128 encode(const set<PII> &s){
  __int128 i=0;
  for(auto &e:s){
    set_bit(i,e);
  }
  return i;
}

tuple<__int128,__int128> encode(const T &t){
  return make_tuple(encode(get<0>(t)),encode(get<1>(t)));
}

int main(){
  for(int w,h;cin>>w>>h,w;){
    set<PII> s;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	int r;
	cin>>r;
	if(r){
	  s.insert({i,j});
	}
      }
    }
    auto b=*s.begin();
    s.erase(s.begin());
    bool flag=false;
    if(s.size()%2){
      for(auto e:s){
	auto is=s;
	is.erase(e);
	for(int i=0;i<4;i++){
	  for(int j=0;j<2;j++){
	    set<tuple<__int128,__int128> > ss;
	    set<PII> bs,es;
	    bs.insert(b);
	    es.insert(e);
	    T ist{bs,es,is};
	    vector<T> v{ist};
	    while(!v.empty()){
	      auto cs=v.back();
	      if(get<2>(cs).empty())break;
	      v.pop_back();
	      if(!ss.insert(encode(cs)).second)continue;
	      //	      cout<<get<2>(cs).size()<<endl;
	      for(auto f:get<2>(cs)){
		//		if(!neighbor(get<0>(cs),f))continue;
		auto vec=make_pair(f.first-b.first,f.second-b.second);
		if(j){
		  swap(vec.first,vec.second);
		}
		for(int k=0;k<i;k++){
		  vec=make_pair(-vec.second,vec.first);
		}
		auto d=PII(e.first+vec.first,e.second+vec.second);
		const auto &rs=get<2>(cs);
		if(d!=f&&rs.count(d)&&neighbor(get<0>(cs),f)&&neighbor(get<1>(cs),d)){
		  auto c=encode(cs);
		  set_bit(get<0>(c),f);
		  set_bit(get<1>(c),d);
		  if(ss.count(c)==0){
		    auto ns=cs;
		    get<0>(ns).insert(f);
		    get<1>(ns).insert(d);
		    get<2>(ns).erase(f);
		    get<2>(ns).erase(d);
		    v.push_back(move(ns));
		  }
		}
	      }
	    }
	    flag|=!v.empty();
	  }
	}
      }
    }
    cout<<(flag?"YES":"NO")<<endl;
  }
}

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

using namespace std;

int main() {
    int a;
    cin >> a;
    for (int n=1; n < 10; ++n) {
        if (a%n == 0 && a/n < 10) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    ///Yeah, I am the backupguy!
    using namespace std;
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int len;
    long long int val=0,n;
    vector<int>vec,vec_1;
    cin>>len;
    for(int i=0;i<len-1;i++)
    {
        cin>>n;
        if(i==0)
            vec_1.push_back(n);
        vec.push_back(n);
    }
    for(int u=0;u<len-2;u++)
    {
        vec_1.push_back(min(vec[u],vec[u+1]));
    }
    vec_1.push_back(vec[vec.size()-1]);
    for(int n=0;n<vec_1.size();n++)
       val+=vec_1[n];
    cout<<val<<endl;
    return 0;
}



Measured memory_bytes: 256
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

#define loop(n) for(int i=0; i<n; i++)
#define loopB(n) for (int j=0; j<n; j++)
#define TAJIKISTAN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in freopen("input.txt", "r" , stdin);
#define out freopen("output.txt", "w", stdout);

#define ll long long
#define ff first
#define ss second

// #pragma GCC optimize("Ofast")
using namespace std;

int* insertX(int arr[], int x, int position) {
    int arraySize = sizeof(arr)/sizeof(arr[0]);
    for (int i=arraySize; i>position; i--) {
        arr[i] = arr[i-1];
    }
    arr[position]=x;
    return arr;
}

double dp[3005][3005];
double heads[3005];

void solve() {
    int N;
    cin>>N;
    loop(N) cin>>heads[i];
    dp[0][0]=(1-heads[0]);
    dp[0][1]=heads[0];
    for (int i=1; i<N; i++) {
        for (int j=0; j<=i+1; j++) {
            if (j==0){
                dp[i][j]=dp[i-1][j]*(1-heads[i]);
                continue;
            } else if (j==i+1) {
                dp[i][j]=dp[i-1][j-1]*heads[i];
            } else {
                dp[i][j]=dp[i-1][j-1]*heads[i]+dp[i-1][j]*(1-heads[i]);
            }
        }
    }
    double sum=0;
    for (int j=N/2+1; j<=N; j++) {
        sum+=dp[N-1][j];
    }
    cout<<setprecision(9)<<sum;
}

int main()
{
    //in out
    //TAJIKISTAN
    int t=1;
    //cin>>t;
    while (t--) {
        solve();
        cout<<'\n';
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  double ans=v[0];
  for(int i=0;i<N-1;i++){
    ans=(ans+(double)v[i+1])/(double)2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define LL long long
#define LD long double
using namespace std;

inline LL mul(LL x,LL y,LL p){
	static LL r; r = x*y-p*(LL)((LD)x*y/p); if (r >= p) r -= p; else if (r < 0) r += p; return r;
}
inline LL power(LL x,LL y,LL p){
	static LL r; r = 1; while (y){ if (y&1) r = mul(r,x,p); x = mul(x,x,p),y >>= 1; } return r;
}
inline LL gcd(LL a,LL b){
	return b ? gcd(b,a%b) : a;
	/*
	#define ctz __builtin_ctzll
	if (!a || !b) return a | b;
	static int t; t = ctz(a|b),a >>= ctz(a);
	while (a ^ b){ if (a < b) swap(a,b); a -= b,a >>= ctz(a); }
	return a << t;
	#undef ctz*/
}
const int chkp[] = {2,3,5,7,11,13,17,19,23,29},len = 10;
inline bool Miller_Rabin(LL n){
	if (n < 2) return 0; if (n == 2 || n == 3 || n == 5) return 1; if (!(n&1) || !(n%3) || !(n%5)) return 0;
	static int s,i; static LL d,a,t;
	s = 0,d = n - 1; while (!(d&1)) ++s,d >>= 1;
	for (i = 0; i < len && chkp[i] < n; ++i){
		a = power(chkp[i],d,n);
		if (a != 1 && a != n - 1){ t = s - 1; while (t--){ a = mul(a,a,n); if (a == n - 1) break; } if (a^(n-1)) return 0; }
	}
	return 1;
}
LL t[100],cnt;
inline LL Pollard_solve(LL n){
    LL x = 0,y = x,t = 1,q = 1,a = (rand()%(n-1))+1;
    for (int k = 2;; k <<= 1, y = x, q = 1){
        for (int i = 1; i <= k; ++i){
            x = (mul(x,x,n)+a)%n,q = mul(q,abs(x-y),n);
            if (!(i & 127)){ t = gcd(q,n); if (t > 1) break; }
        }
        if (t > 1 || (t = gcd(q,n)) > 1) break;
    }
    if (t == n){ t = 1; while (t == 1) t = gcd(abs((x=(mul(x,x,n)+a)%n)-y),n); }
    return t;
}
inline void Pollard(LL n){
	if (n == 1) return;
	if (Miller_Rabin(n)){ t[++cnt] = n; return; }
	LL p = n; while (p == 1 || p == n) p = Pollard_solve(n);
	Pollard(n/p),Pollard(p);
}
inline void divide(LL n){
	LL i;
	for (i = 2; i <= 100000 && i * i <= n; ++i) while (n % i == 0) t[++cnt] = i,n /= i;
	Pollard(n);
}

LL n,ans;
inline void exgcd(LL a,LL b,LL &d,LL &x,LL &y){
	if (!b){ d = a,x = 1,y = 0; }
	else{ exgcd(b,a%b,d,y,x),y -= (a/b) * x; }
}
inline void solve(LL xxx,LL yyy){
	if (gcd(xxx,yyy) > 1) return;	//x * t1 - y * t2 == 1
	LL a,b,c,t,d,x0,y0;
	a = xxx,b = yyy,c = 1;
	exgcd(a,b,d,x0,y0);
	if (x0 <= 0 && y0 > 0){
		d = (-x0) / b + 1;
		x0 += d * b;
		y0 -= d * a;
	}
	LL mnx,mxy;
	if (x0 < 0) t = (-x0) / b,x0 += t * b,y0 -= t * a;
	if (x0 > 0) t = (x0-1) / b,x0 -= t * b,y0 += t * a;
	while (x0 < 0) x0 += b,y0 -= a;
	while (x0 > b) x0 -= b,y0 += a;
	if (y0 == 0) y0 -= a,x0 += b;
	mnx = x0,mxy = y0;
	
	if ((LD)mnx * xxx > 0 && (LD)mnx * xxx < ans) ans = min(ans,mnx * xxx);
	// x = x0 + t * b;
	// y = y0 - t * a;
	// t \subset Z 
}
int nxt[100];
int CNT;
inline void bl(int dep,LL v){
	if (dep > cnt){
		solve(v,n/v);
		++CNT;
		return;
	}
	if (t[dep] != t[dep-1])bl(nxt[dep],v);
	bl(dep+1,v*t[dep]);
}
int main(){
	LL i,j;
	cin >> n,n <<= 1;
	//for (i = 1; i <= 10000000; ++i) if (i * (i+1) % n == 0){ cout << i << '\n'; return 0; }
	ans = n;
	divide(n);
	sort(t+1,t+cnt+1);
	for (i = 1; i <= cnt; ++i)
	for (nxt[i] = cnt+1,j = i; j <= cnt; ++j) if (t[j] != t[i]){ nxt[i] = j; break;}
	bl(1,1);
	cout << ans-1 << '\n';
//	cerr << CNT << '\n';
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000LL;

ll n, m, s[15], d[101], dp[1<<15];

ll labs(ll a) { return a < 0 ? -a : a; }

int main() {
  while (scanf("%lld%lld", &n, &m), n) {
    ll all_sum = 0;
    for (ll i = 0; i < n; i++) scanf("%lld", &s[i]), all_sum += s[i];
    for (ll i = 0; i < m; i++) scanf("%lld", &d[i]);
    sort(d, d+m);
    d[m] = INF;
    for (ll i = 0; i < (1 << n); i++) dp[i] = INF;
    dp[0] = 0;
    for (ll counter = 0; counter < n; counter++) {
      for (ll x = 0; x < (1 << n); x++) {
        for (ll z = 0; z < n; z++) {
          ll y = 1 << z;
          if (x & y) continue;
          ll sum = 0, s1 = 0, s2 = 0;
          for (ll i = 0; i < n; i++) if (x & (1 << i)) s1 += s[i];
          s2 = s1 + s[z];
          ll num = lower_bound(d, d+m+1, s1) - d;
          for (ll i = num; d[i] < s2; i++) {
            sum += min(labs(d[i] - s1), labs(s2 - d[i]));
          }
          dp[x|y] = min(dp[x|y], dp[x] + sum);
        }
      }
    }
    ll ans = dp[(1 << n) - 1];
    for (ll i = 0; i < m; i++) if (d[i] > all_sum) ans += d[i] - all_sum;
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 3024