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

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt(); // 窓
		int B = nextInt(); // カーテン

		int res = -1;
		if(A > 0 && A < 10 && B > 0 && B < 10)res = A*B;
		out.println(res);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int L, R, D;
    cin >> L >> R >> D;
    cout << R/D - (L-1)/D << endl;
}


Measured memory_bytes: 3616
def solve(n,x):
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for h in range(j+1,n+1):
                if i+j+h == x:
                    ans += 1
    print(ans)

while 1:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    else:
        solve(n,x)


Measured memory_bytes: 5600
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[] arrived;
    static ArrayList<ArrayList<Integer>> li;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        double ans = 0;
        int i = 0;
        for(int aa : a){
            ans += (double)aa;
            if(i != 0){
               ans /= 2d; 
            }
            i++;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];

  ll ans = 0;
  sort(h.begin(), h.end());
  rep(i, n - k) ans += h[i];
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = c * d / __gcd(c, d);
    cout << (b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / e - (a - 1) / e) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string rev=s;
	int n=s.size();
	reverse(rev.begin(),rev.end());
	string s1=s.substr(0,(n-1)/2);
	string s1rev=s1;
	reverse(s1rev.begin(),s1rev.end());
	string s2=s.substr((n+2)/2);
	string s2rev=s2;
	reverse(s2rev.begin(),s2rev.end());
	if(s==rev && s1==s1rev && s2==s2rev){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}



signed main () {
    int x,n;cin >>x>>n;
    if(n==0){
        cout << x<<endl;
        return 0;
    }
    vector<int> abl;
    abl.pb(x);
    rep(i,100){
        rep(j,2){
            abl.pb(x+(i+1)*(j==0?-1:1));
        }
    }

    vector<int> a(n);
    rep(i,n)cin >>a[i];

    rep(i,188){
        bool fl=true;
        rep(j,n){
            if(abl[i]==a[j]){
                fl=false;
                break;
            }
        }
        if(fl){
            cout << abl[i]<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int x[8], vec[8];
	scanf("%d%d%d%d", &x[0], &x[1], &x[2], &x[3]);
	vec[0]=x[2]-x[0];
	vec[1]=x[3]-x[1];
	for (int i = 2; i <= 6; i+=2)
	{
		vec[i]=-vec[i-1];
		vec[i+1]=vec[i-2];
	}
	for (int i = 4; i <=6 ; i+=2)
	{
		x[i]=x[i-2]+vec[i-2];
		x[i+1]=x[i-1]+vec[i-1];
	}
	printf("%d %d %d %d", x[4], x[5], x[6], x[7]);
	return 0;
}

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

int suitToInt(string suit);
string intToSuit(int i);

int main(void){
  bool card[4][13] = {};
  string rSuit;
  int number;
  int numCard;
  
  cin >> numCard;
  
  for(int i = 0; i < numCard; i++) {
    cin >> rSuit >> number;
    card[suitToInt(rSuit)][number - 1] = true;
  }
  
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 13; j++) {
      if(!card[i][j]) {
        cout << intToSuit(i) << " " << j + 1 << endl;
      }
    }
  }
  
}

int suitToInt(string suit) {
  switch(suit[0]) {
    case 'S': return 0;
    case 'H': return 1;
    case 'C': return 2;
    case 'D': return 3;
  }
}

string intToSuit(int i) {
  switch(i) {
    case 0: return "S";
    case 1: return "H";
    case 2: return "C";
    case 3: return "D";
  }
}

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

using namespace std;

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

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

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

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

double dp[10010][21][21];
int x[20],y[20];
D dist[20][20];

bool ok[20][20][20];

int main(void){
	int n;
	cin >> n;
	D r,theta;
	cin >> r >> theta;
	int limit=1*r;

	rep(i,n) cin >> x[i] >> y[i];

	rep(i,n)rep(j,n){
		int dx=(x[i]-x[j]);
		int dy=(y[i]-y[j]);
		dist[i][j]=sqrt(1.0*dx*dx+1.0*dy*dy);
	}

	rep(i,limit+1)rep(j,n+1)rep(k,n+1) dp[i][j][k]=inf;
	int ans=0;
	range(cp,1,n){
		if(dist[cp][0]<=r){
			dp[1][cp][0]=dist[cp][0],ans=1;
		}
	}
	rep(pp,n)rep(cp,n)rep(np,n){
		if(pp==cp) continue;
		if(cp==np) continue;
		int cx=x[cp]-x[pp],cy=y[cp]-y[pp];
		int nx=x[np]-x[cp],ny=y[np]-y[cp];
		D dot=1.0*cx*nx+1.0*cy*ny;
		dot/=(dist[cp][pp]*dist[np][cp]);
		dot=max<D>(-1,dot);
		dot=min<D>(1,dot);
		D angle=acos(dot);
		angle*=180.0/pi;
		if(angle>180.0) angle=360.0-angle;
		if(angle<=theta) ok[pp][cp][np]=true;
	}


	rep(i,limit)rep(cp,n)rep(pp,n){
		if(dp[i][cp][pp]==inf) continue;
		if(cp==pp) continue;
		rep(np,n){
			if(np==cp) continue;
			D add=dist[cp][np];
			if(dp[i][cp][pp]+add>r) continue;
			if(ok[pp][cp][np]==false) continue;
			dp[i+1][np][cp]=min<D>(dp[i+1][np][cp],dp[i][cp][pp]+add);
			ans=max(ans,i+1);
		}
	}

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

Measured memory_bytes: 35708
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0&&b%i==0)c--;
        if(c==0){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)

vector<vector<pair<int, int>>> Sep;
char C[64][64];

int main() {

	int N, A[2][128];

	scanf("%d", &N);

	rep(i, 2) rep(j, N) scanf("%d", &A[i][j]);

	int S[2][128];

	rep(i, N) {
		if (!i) S[0][i] = A[0][i];
		else S[0][i] = S[0][i - 1] + A[0][i];
	}

	rep(i, N) {
		if (!i) S[1][N - i - 1] = A[1][N - i - 1];
		else S[1][N - i - 1] = S[1][N - i] + A[1][N - i - 1];
	}

	int ans = 0;

	rep(i, N) {
		ans = max(ans, S[0][i] + S[1][i]);
	}


	printf("%d\n", ans);

	return 0;
}


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

const int N = 1e5+5;
int a[3][N];
int cache[N][3];
int n;

int solve(int day, int curr_activity){
	if( day == n+1 ){ return 0; }
	if( cache[day][curr_activity] != -1 ){ return cache[day][curr_activity]; }
	int &ans = cache[day][curr_activity];

	int a1 = 0;
	for(int i=0; i<3; ++i){
		if( i!= curr_activity ){
			a1 = max(a1, solve(day+1, i) + a[i][day] );
		}
	}
	ans = a1;
	return ans;

}


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

	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>a[0][i]>>a[1][i]>>a[2][i];
	}
	memset(cache,-1,sizeof(cache));
	int ans = 0;
	for(int i=0; i<3; ++i){
		ans = max(ans, solve(0,i));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <string.h>
#include <math.h>

int decode(char a[256]);
char* encode(int num);

char mcxi[4]={'i','x','c','m'};

int main(){
	int n,num,i,j,t;
	char a[256],b[256];
	scanf("%d",&n);
	while(n--){
		char s[256];j=0;
		scanf("%s %s",a,b);
		num = decode(a)+decode(b);
		for(i=3;i>-1;i--){
			t=(int)(num/pow(10.0,i))%10;
			if(t>1){
				s[j++]=t+48;
				s[j++]=mcxi[i];
			}
			else if(t==1) s[j++] = mcxi[i];
		}
		s[j] = '\0';
		printf("%s\n",s);
	}
	return 0;
}

int decode(char a[256]){
	int i,j,len=strlen(a);
	int num=0;
	for(i=0;i<4;i++){
		for(j=0;j<len;j++){
			if(mcxi[i]==a[j]){
				if(a[j-1]<58&&j){
					num += (a[j-1]-48)*(int)pow(10.0,i);
				}
				else num+=(int)pow(10.0,i);
				break;
			}
		}
	}
	return num;
}
char* encode(int num){
	int i,j=0,t;
	char s[256];
	for(i=3;i>-1;i--){
		t=(int)(num/pow(10.0,i))%10;
		if(t>1){
			s[j++]=t+48;
			s[j++]=mcxi[i];
		}
		else if(t==1) s[j++] = mcxi[i];
	}
	s[j] = '\0';
	return s;
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  vector<pair<long, long>> data(N);
  for(int i = 0; i < N; i++)data.at(i).first = 1;
  data.at(0).second = 1;
  long x, y;
  for(int i = 0; i < M; i++){
    cin >> x >> y;
    x--;
    y--;
    data.at(x).first--;
    data.at(y).first++;
    if(data.at(x).second == 1){
      if(data.at(x).first == 0)data.at(x).second = 0;
      data.at(y).second = 1;
    }
  }
  long ans = 0;
  for(int i = 0; i < N; i++)if(data.at(i).second == 1)ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007
#define BOX 200000

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define uni(a) a.erase(unique(begin(a), end(a)), end(a))
#define sum(a) accumulate(begin(a), end(a), 0)


template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    ll N;
    cin >> N;
    int buka[200000];
    memset(buka, 0x00, sizeof(buka));
    rep(i, 0, N - 1) {
        int temp;
        cin >> temp;
        buka[temp - 1]++;
    }
    rep(i, 0, N) {
        cout << buka[i] << endl;
    }
    return 0;

}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main() {

  int N; cin >> N;
  ll a[N];
  rep(i,N) cin >> a[i];

  int ans = 0;
  while (true){
    bool b = true;
    rep(i,N) if (a[i]%2 != 0 ) b = false;
    if (!b) break;
    rep(i,N) a[i] /= 2;
    ans++;
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> used(2 * n, 0);
        set<int> t, h;
        for(int i = 0; i < n; i++)
        {
            int x; cin >> x;
            x--;
            t.insert(x);
            used[x] = 1;
        }
        for(int i = 0; i < 2 * n; i++) if(not used[i]) h.insert(i);

        int st = n, sh = n;
        bool turn = false;
        int k = -1;
        while(st > 0 and sh > 0)
        {
            if(turn == false)
            {
                auto itr = t.lower_bound(k);
                if(itr == t.end()) k = -1;
                else
                {
                    t.erase(itr);
                    k = *itr;
                    st--;
                }
            }
            else
            {
                auto itr = h.lower_bound(k);
                if(itr == h.end()) k = -1;
                else
                {
                    h.erase(itr);
                    k = *itr;
                    sh--;
                }
            }
            turn = (turn ? false : true);
        }
        cout << sh << endl;
        cout << st << endl;
    }
    return 0;
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

vector<ll> d;
vector<ll> powv(vector<ll> &a){
    vector<ll> ret(a.size());
    REP(a.size()){
        ret[i]=a[a[i]];
    }
    return ret;
}
vector<ll> addv(vector<ll> &a,vector<ll> &b){
    vector<ll> ret(a.size());
    REP(a.size()){
        ret[i]=b[a[i]];
    }
    return ret;
}
void swapv(vector<ll> &a,ll b,ll c){
    swap(a[b],a[c]);
}
void solve(long long N, std::vector<long long> x, long long M, long long K, std::vector<long long> a){
    REP(N-1){
        d.push_back(x[i+1]-x[i]);
    }
    vector<ll> h(N-1);
    iota(h.begin(),h.end(),0);
    REP(M){
        swapv(h,a[i],a[i]-1);
    }
    vector<ll> ans(N-1);
    iota(ans.begin(),ans.end(),0);
    while(K>0){
        if((K&1)>0){
            ans=addv(ans,h);
        }
        K>>=1;
        h=powv(h);
    }
    cout<<x[0]<<endl;
    REP(x.size()-1){
        x[i+1]=x[i]+d[ans[i]];
        cout<<x[i+1]<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        a[i]--;
    }
    solve(N, std::move(x), M, K, std::move(a));
    return 0;
}


Measured memory_bytes: 5956
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long

int main(){
//A 13:25 13:37
//B 13:37
    int N;
    cin >> N;
    vector<double> X(N);
    vector<string> U(N);
    long double ans = 0;
    int multi = 0;
    /////////////////////
    for (int i = 0; i < N;i++)
    {
        cin >> X[i] >> U[i];
        if(U[i] == "JPY"){
            ans += X[i];
        }
        else{

            ans += X[i] * 380000;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int sum=0;
  if(k<=n) sum+=k*x;
  else sum+=n*x;
  int d=n-k;
  if(d>0) sum+=d*y;
  
  cout<<sum;
}
  

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
char s[100],t[100];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	scanf("%s",t);
	m=strlen(t);
	for(int i=n-m;i>=0;i--)
	{
		for(int j=0;j<=m;j++)
		{
			if(j==m)
			{
				for(int l=0;l<i;l++)
				{
					if(s[l]!='?')
						printf("%c",s[l]);
					else
						printf("a");
				}
				for(int l=0;l<m;l++)
					printf("%c",t[l]);
				for(int l=i+m;l<n;l++)
				{
					if(s[l]!='?')
						printf("%c",s[l]);
					else
						printf("a");
				}
				return 0;
			}
			if(s[i+j]=='?')
				continue;
			else
				if(s[i+j]!=t[j])
					break;
		}
	}
	printf("UNRESTORABLE");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, R; cin >> N >> R;

    if(N >= 10) cout << R << endl;
    else{
        cout << R + 100 * (10 - N) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
// ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
string s,t;
int N,K;

vi A,B;
vpii datas;
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
}uf;
int main(){
	cin>>N;
	cout<<(N-1)/2<<endl;

}





Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ll a; cin>>a;
    ll m[a];
    for(int q=0; q<a; q++) cin>>m[q];
    ll o = 0;
    for(int q=0; q<a; q++){
        for(int w=q+1; w<a; w++){
            for(int e=w+1; e<a; e++){
                vec<ll> n = {m[q], m[w], m[e]};
                sort(all(n));
                if(n[0]+n[1]>n[2] && n[1]!=n[0] && n[1]!=n[2]) o++;
            }
        }
    }
    cout<<o;
}

Measured memory_bytes: 3648
from heapq import heappush,heappop
N=int(input())
A=list(map(int,input().split()))
X=0
Z=0
mae=[]
ushiro=[]
for i in range(N):
    X+=A[i]
    heappush(mae,A[i])
    Z-=A[i+2*N]
    heappush(ushiro,-1*A[i+2*N])
maedata=[0]*(N+1)
ushirodata=[0]*(N+1)
maedata[0]=X
ushirodata[0]=Z
for i in range(N):
    X+=A[i+N]
    heappush(mae,A[i+N])
    X-=heappop(mae)
    maedata[i+1]=X
    
    Z-=A[2*N-i-1]
    heappush(ushiro,-1*A[2*N-i-1])
    Z-=heappop(ushiro)
    ushirodata[i+1]=Z
ans=-1*float('inf')
for i in range(N+1):
    ans=max(ans,maedata[i]+ushirodata[N-i])
print(ans)

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

int main() {
	string S, T;
	int flag = 1;
	
	cin >> S >> T;

	for (int i = 0; i < S.length(); i++)
		if (S[i] != T[i]) flag = 0;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3

def main():
    sn = input()
    sa = input().split(' ')
    a = [int(s) for s in sa]

    a.sort()
    a.reverse()
    na = 0
    nb = 0
    for n in a[0::2]:
        na += n
    for n in a[1::2]:
        nb += n

    print(na - nb)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def dfs(now,val,cost):
    if now == n:
        return val - cost
    else:
        return max(dfs(now+1,val+v[now],cost+c[now]),dfs(now+1,val,cost))

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

print(dfs(0,0,0))


Measured memory_bytes: 2940
n=int(input())
seq=[]
for i in range(n):
    seq.append(input())
dic={}
for i in range(n):
    if seq[i] in dic:
        dic[seq[i]]+=1
    else:
        dic[seq[i]]=1
M=0
for i in dic.values():
    M=max(M,i)
l=[]
for i in dic.keys():
    if dic[i]==M:
        l.append(i)
for i in sorted(l):
    print(i)

Measured memory_bytes: 99664
n,k,c=map(int,input().split())
s=input()
l,r=[],[]
i=0
while i<n:
    if s[i]=="o":
        l.append(i)
        i+=c+1
    else:
        i+=1
i=n-1
while i>-1:
    if s[i]=="o":
        r.append(i)
        i-=c+1
    else:
        i-=1
l=l[:k]
r=r[:k]
r=r[::-1]
for i in range(k):
    if l[i]==r[i]:
        print(l[i]+1)
#print(l)
#print(r)

Measured memory_bytes: 22008
import collections

n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
l = []
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
dec = collections.deque(sorted(l))
if n > 1:
    for _ in range(n-1):
        if len(dec) == 0:
            break
        dec.pop()

print(sum(dec))

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

int main() {
	int m[10];
	int ans[3];
	for(int i=0; i<10; i++) scanf("%d", &m[i]);

	ans[0] = 0; ans[1] = 0; ans[2] = 0;
	for(int j=0; j<10; j++) {
		if(m[ans[0]] < m[j]) {
			ans[0] = j;
		}
	}
	if(ans[1] == ans[0]) {
		if(ans[1] == 0) ans[1] = 1;
		else ans[1] = ans[0]-1;
	}
	for(int j=0; j<10; j++) {
		if(m[ans[1]] < m[j] && ans[0] != j) {
			ans[1] = j;
		}
	}
	if(ans[2] == ans[0]) {
		if(ans[2] == 0) ans[2] = 2;
		else ans[2] = ans[0]-2;
	}
	for(int j=0; j<10; j++) {
		if(m[ans[2]] < m[j] && ans[0] != j && ans[1] != j) {
			ans[2] = j;
		}
	}
	printf("%d\n%d\n%d\n", m[ans[0]], m[ans[1]], m[ans[2]]);
	return 0;
}


Measured memory_bytes: 2716
#include <bits/stdc++.h> 
using namespace std;
const int N=1e5+5;
int c[N]={0};
//int flag[N]={0};
int main(){
	int n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		c[a-1]++;
		c[a+1]++;
		c[a]++;
	}
	int max=c[0];
	for(int i=1;i<100001;i++){
		if(max<c[i]) max=c[i];
	}
	cout << max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  if ( c == "a" || c == "i" || c == "u" || c == "e" || c == "o" ) {
      cout << "vowel" <<endl;
  }
  else {
      cout << "consonant" <<endl;
  }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] arr = new long[n + 1];
		long[] sums = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			int x = sc.nextInt();
			arr[i] = arr[i - 1] + x;
			sums[i] = sums[i - 1] + Math.max(x, 0);
		}
		long max = Long.MIN_VALUE;
		for (int i = k; i <= n; i++) {
			long sum = arr[i] - arr[i - k];
			long maxSum = sums[n] - (sums[i] - sums[i - k]);
			max = Math.max(max, Math.max(maxSum, maxSum + sum));
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 61096
#include "bits/stdc++.h"
using namespace std;

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


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

    int H;
    int A;
    cin >> H >> A;
    int cnt = 1;

    while (1) {
        if (0 >= H - A * cnt) {
            break;
        }
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3660
def i_sort(A,n,g):
    global count
    
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            count = count + 1
        A[j + g] = v
        
def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
        
if __name__ == '__main__':
    N = int(input())
    R = [int(input()) for i in range(N)]
    
    count = 0
    G = []
    m = 0
    
    shellsort(R,N)
    
    print(m)
    print(" ".join(map(str,G)))
    print(count)
    for i in range(N):
        print(R[i])


Measured memory_bytes: 45520
S = int(input())
s = int(S**.5)
if s*s != S:
    s += 1
    if s > 10**9:
        s = 10**9

#x1,y1は固定
x1 = 0
y1 = 0
x2 = 0
y2 = 0
x3 = 0
y3 = 0

#abs(x2y3-x3y2)が2Sとなる
x2 = s
y3 = s
x3 = 1
y2 = x2*y3 - S

print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>

using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmax(T &a, T b)
{
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int N;
  int K;

  cin >> N >> K;

  int digits = 0;

  while (true) {
    N /= K;
    digits++;
    if (N == 0) {
      break;
    }
  }

  cout << digits;

  return 0;
}


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

#define V vector
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define prec(x) cout<<fixed<<setprecision(x)
#define f(i,a) for(int i = 0 ; i < a ; i++)
#define ff first
#define ss second
#define all(x) (x).begin() ,(x).end()

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

ll binpow(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}

void solve()
{
	int a , b , c , k;
	cin >> a >> b >> c >> k;

	int cnt = 0;

	while (b <= a)
		b *= 2 , cnt++;
	if (cnt > k)
	{
		cout << "No\n";
		return;
	}

	while (c <= b)
		c *= 2 , cnt++;

	if (cnt <= k)
		cout << "Yes\n";
	else
		cout << "No\n";


}


int main() {


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


	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}





Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int d[10][10];
int h, w;
int c[10][10];
int a[222][222];
signed main() {
	cin >> h >> w;
	rep(i, 10) {
		rep(j, 10) {
			cin >> c[i][j];
			d[i][j] = c[i][j];
		}
	}
	rep(i, h) {
		rep(j, w)cin >> a[i][j];
	}
	rep(k, 10) {
		rep(i, 10) {
			rep(j, 10) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] != -1)ans += d[a[i][j]][1];
		}
	}
	cout << ans << endl;
	ggr
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

string dfs(int k, string op, const string& val) {
  if(k == 3) {
    int now = val[0] - '0';
    for(int i=0;i<3;++i) {
      if(op[i] == '+') now += val[i+1] - '0';
      else now -= val[i+1] - '0';
    }
    if(now == 7) return op;
    else return "";
  } else {
    op.push_back('+');
    string tmp1 = dfs(k+1, op, val);
    op.back() = '-';
    string tmp2 = dfs(k+1, op, val);
    op.pop_back();
    if(SZ(tmp1) > 0) return tmp1;
    else return tmp2;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  string op = "";
  op = dfs(0, op, s);
  cout << s[0];
  for(int i=0;i<3;++i) {
    cout << op[i] << s[i+1];
  }
  cout << "=7\n";
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int n , k;
 cin >> n >> k;
 string s;
 cin >> s;
 if(s[k-1] == 'A')s[k-1] = 'a';
 else if(s[k-1] == 'B')s[k-1] = 'b';
 else s[k-1] = 'c';
 cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int h, w, c;

bool ok(int i, int j)
{
	return i >= 0 && j >= 0 && i < h && j < w;
}

void show(mat& a)
{
	for (int i = 0; i < a.size(); i++){
		for (int j = 0; j < a[i].size(); j++){
			printf("%d ", a[i][j]);
		}
		puts("");
	}
}

bool vis[8][8];
int search(int d, mat panel)
{
	//printf(":  %d\n", d);
	//show(panel);
	
	if (d == 0){
		if (panel[0][0] != c) return 0;
		memset(vis, 0, sizeof(vis));
		vis[0][0] = true;
		queue<int> que;
		que.push(0);
		que.push(0);
		int res = 1;
		while (que.size()){
			int x = que.front(); que.pop();
			int y = que.front(); que.pop();
			for (int i = 0; i < 4; i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (!ok(nx, ny)) continue;
				if (vis[nx][ny]) continue;
				if (panel[nx][ny] != c) continue;
				que.push(nx);
				que.push(ny);
				vis[nx][ny] = true;
				res++;
			}
		}
		return res;
	}
	
	int res = 0;
	for (int i = 1; i <= 6; i++){
		mat tp = panel;
		memset(vis, 0, sizeof(vis));
		vis[0][0] = true;
		queue<int> que;
		que.push(0);
		que.push(0);
		while (que.size()){
			int x = que.front(); que.pop();
			int y = que.front(); que.pop();
			tp[x][y] = i;
			for (int dir = 0; dir < 4; dir++){
				int nx = x + dx[dir];
				int ny = y + dy[dir];
				if (!ok(nx, ny)) continue;
				if (vis[nx][ny]) continue;
				if (panel[nx][ny] != panel[0][0]) continue;
				que.push(nx);
				que.push(ny);
				vis[nx][ny] = true;
			}
		}
		res = max(res, search(d - 1, tp));
	}
	return res;
}

int main()
{
	while (scanf("%d %d %d", &h, &w, &c), h){
		mat panel(h, vec(w));
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				scanf("%d", &panel[i][j]);
			}
		}
		printf("%d\n", search(5, panel));
	}
}

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

int p[100005];
int link[100005];

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

void unite(int a, int b){
	a=find(a);
	b=find(b);
	if(a==b) return;
	if(a>b) swap(a,b);
	link[b]=a;
}

int main(){
	int n,m; cin >> n >> m;
	for(int i=1;i<=n;i++) cin >> p[i];
	for(int i=1;i<=n;i++) link[i]=i;

	while(m--){
		int x,y;
		cin >> x >> y;
		unite(p[x],p[y]);
	}

	int res=0;
	for(int i=1;i<=n;i++){
		if(find(i)==find(p[i])) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;


int main()
{
	int ans=0;
	int x,y,z;
	cin>>x>>y>>z;
	while(x>z+y)
	{
		x-=z+y;
		if(x>=z) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<tapu, Vtapu, greater<tapu> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
 
LL N;
LL X[SIZE],Y[SIZE];
ld solve(VI v){
  ld dir=0;
  ld dirsum=0;
  v.pb(0);  
  pr now=pr(0,0);
  REP(i,N+1){
    ld ndir=atan2(Y[v[i]]-now.second,X[v[i]]-now.first);
        
    dirsum+=min(2*M_PI-abs<ld>(ndir-dir),abs<ld>(ndir-dir));
  //  cout << dir*360/(2*M_PI) << endl;
    dir=ndir;  
    now=pr(X[v[i]],Y[v[i]]);
  }
  //cout << dirsum << endl;
  //outputVI(v);
  return dirsum;
}
signed main(){
  cout << setprecision(10) << endl;
  cin >> N;
  VI v;
  EFOR(i,1,N){
    cin >> X[i] >> Y[i];
  }
  EFOR(i,1,N) v.pb(i);
  ld ans=INF;
  do{
    MN(ans,solve(v));
  }while(next_permutation(ALL(v)));
  //cout << ans << endl;
  cout << ans*360*1.0/(2*M_PI) << endl;
  return 0;
}



Measured memory_bytes: 3556
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int i;
int ara[10];
for (i=0;i<10;i++)
{
scanf("%d",&ara[i]);
}
sort(ara,ara+10);
for (i=9;i>6;i--)
{
printf("%d\n",ara[i]);
}
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
  	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
	Scanner inp=new Scanner(System.in);
	String a=inp.next();
	
	for(int i=0;i<a.length();i++){
		if(a.charAt(i)=='C'){
			while(i<a.length()){
				if(a.charAt(i)=='F'){
					a="Yes";
					i=a.length();
				}
				i++;
			}
		}
	}
	if(a!="Yes")a="No";
	System.out.println(a);
	}
}

Measured memory_bytes: 9680