akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int v = in.nextInt(), e = in.nextInt();
			int[][] mat = new int[v][v];
			for (int i = 0; i < v; i++) {
				Arrays.fill(mat[i], -1);
			}

			for (int i = 0; i < e; i++) {
				int s = in.nextInt(), t = in.nextInt(), d = in.nextInt();
				mat[s][t] = d;
			}

			int ans = INF;

			int[][] dp = new int[1 << v][v];
			for (int k = 0; k < v; k++) {

				dp = new int[1 << v][v];
				for (int i = 0; i < 1 << v; i++) {
					Arrays.fill(dp[i], INF);
				}
				dp[0][k] = 0;

				for (int s = 0; s < 1<<v; s++) {
					for (int now = 0; now < v; now++) {
						for (int to = 0; to < v; to++) {
							if ((s >> to & 1) == 0 && mat[now][to] != -1) {
								dp[s|1<<to][to] = Math.min(dp[s|1<<to][to], dp[s][now] + mat[now][to]);
							}
						}
					}
				}

				ans = Math.min(ans, dp[(1<<v)-1][k]);

			}


			out.println(ans == INF ? -1 : ans);


		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}



Measured memory_bytes: 59152
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,C;
ll A,B,W;
ll T,a,b;
double v[55],D[55],Q,l,r;
ll ans=0;
//bool D[100005];
ll S[50][50]={};
string str1[55],str2="abcdefghijklmnopqrstuvwxyz";
map<string,int> m;

int main(){
	cin>>N;
	cout<<N*800-(N/15)*200<<endl;
	return 0;
}


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

int dx[] = {1, 1, 0, 0};
int dy[] = {1, 0, 1, 0};

int N;
vector<bool> a;
vector<bool> ans;


vector<bool> arr(bool fst, bool scd){
  vector<bool> tmp(N + 2, 0);
  tmp[N] = fst, tmp[0] = fst;
  tmp[1] = scd, tmp[N+1] = scd;
  
  for(int i = 2; i < N; i++){
    tmp[i] = (tmp[i-2] ^ tmp[i-1]) ^ a[i-1];
  }
  bool clr = 1;
  for(int i = N-1; i > 1; i--){
    bool prv = (tmp[i+2] ^ tmp[i+1]) ^ a[i+1];
    if(prv ^ tmp[i]) clr = 0;
  }
  
  if(!clr) tmp.clear();
  return tmp;
}

int main(){
  cin >> N;
  a.resize(N+2);
  ans.resize(N+1);
  for(int i = 1; i <= N; i++){
    char c; cin >> c;
    if(c == 'o') a[i] = 1;
    else a[i] = 0;
  }
  a[0] = a[N], a[N+1] = a[1];
  
  bool done = 0;
  for(int i = 0; i < 4; i++){
    ans = arr(dx[i], dy[i]);
    if(!ans.empty()){
      for(int i = 1; i <= N; i++){
        if(ans[i])  cout << 'S';
        else  cout << 'W';
      }
      done = 1;
      break;
    }
  }
  if(!done) cout << "-1" << endl;
}

Measured memory_bytes: 384
//https://atcoder.jp/contests/dp/tasks/dp_g
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> in_d (n);
	//vector<int> ind (n);
	vector<int> vis (n);
	vector<vector<int>> g (n);
	vector<int> dp (n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[x-1].push_back(y-1);
		++in_d[y-1];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		//in_d = ind;
		if (in_d[i] == 0 && !vis[i]) {
			queue<int> q;
			q.push(i);
			while (q.size()) {
				int s = q.front();
				++vis[s];
				q.pop();
				for (auto x:g[s]) {
					if (--in_d[x] == 0 && !vis[x]) {
						q.push(x);
					}
					dp[x] = max(dp[x], dp[s]+1);
					ans = max(ans, dp[x]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string n;
    cin >> n;
    for(int i=0; i<3; i++) {
        if(n[i] == '7') {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
pair<int, int> queue[N];

int main(){
  int nums;
  cin >> nums;
  for(int i = 0;i < nums; i ++){
    cin >> queue[i].first;
    queue[i].second = i+1;
  }
  sort(queue,queue+nums);
  for(int i = 0; i < nums; i ++) cout << queue[i].second << " ";
  cout << endl;
  return 0;
}

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

int main(){
    ll x; cin >> x;
    vector<ll> A(1001);
    vector<ll> B(2001);
    for(int i=1; i<=1000; i++){
        A[i] = pow(i,5);
        B[i] = A[i];
        B[i+1000] = -A[i];
    }

    for(int i=0; i<1001; i++){
        for(int j=0; j<2001; j++){
            if(A[i] == x + B[j]){
                cout << i << " ";
                if(j > 1000) cout << -(j-1000);
                else cout << j;
                cout << endl;
                exit(0);
            }
        }
    }
}

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

int main(){
  ios_base::sync_with_stdio(false);
  
  int n;
  string name;
  long long march[5] = {};

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> name;
    if(name[0] == 'M')march[0]++;
    if(name[0] == 'A')march[1]++;
    if(name[0] == 'R')march[2]++;
    if(name[0] == 'C')march[3]++;
    if(name[0] == 'H')march[4]++;
  }
  
  long long ans = 0;

  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++){
        if(march[i] && march[j] && march[k])ans += march[i] * march[j] * march[k]; 
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}



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

int minimumcost(int n,int k,vector<int>&v)
{
   if(k>=n)
   {
        return v[n-1]-v[0];
  }
    vector<int>dp(n,0);
    dp[0]=0;
    for(int i=1;i<=k;i++)
    {
        dp[i]= abs(v[i]-v[0]);
    }

    for(int i=k+1;i<n;i++)
    {
        dp[i]=dp[i-k]+abs(v[i]-v[i-k]);
        for(int j=i-1;j>=i-k;j--)
        {
            dp[i] = min(dp[i],dp[j] + abs(v[i]-v[j]));
        }
    }
    return dp[n-1];
}

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

	vector<int>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}

	cout<<minimumcost(n,k,v);
}

Measured memory_bytes: 1024
N = int(input())
S = input()
cnt_l = 0
cnt_r = 0
for s in S:
    if s == '(':
        cnt_l += 1
    else:
        if cnt_l > 0:
            cnt_l -= 1
        else:
            cnt_r += 1
print('('*cnt_r+S+')'*cnt_l)

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;


    int n;
    scn(n);

    vector<int>cnt(n+3,0);

    for(int i=0; i<n; i++){
        int x;
        scn(x);

        cnt[x]++;
    }

    for(int i=1+n%2; i<n; i += 2){
        if(cnt[i] != 2){
            cout<<0;
            return 0;
        }
    }

    if(n%2){
        if(cnt[0] != 1){
            cout<<0;
            return 0;
        }
    }
    else{
        if(cnt[0]){
            cout<<0;
            return 0;
        }
    }
    int ans = 1;
    for(int i=1+n%2; i<n; i += 2) ans = mulmod(ans , 2);

    cout<<ans;



    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 640
a,b=map(int,input().split())
m=[[0 for _ in range(100)] for _ in range(100)]
#paint lower half as 1 
for i in range(50,100):
    for j in range(100):
        m[i][j]=1
a-=1 #0 means black
b-=1 #1 means white 
#paint chess board like pattern of b white dots in upper half
for i in range(0,48,2):
    if b==0:
        break
    for j in range(0,100,2):
        m[i][j]=1
        b-=1
        if b==0:
            break
     
#now paint a black dots in lower half
for i in range(99,50,-2):
    if a==0:
        break
    for j in range(0,100,2):
        m[i][j]=0
        a-=1
        if a==0:
            break
print(100,100)
for i in range(100):
    for j in range(100):
        if m[i][j]==0:
            print('.',end='')
        else:
            print('#',end='')
    print()



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

int main() {
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int d = stoi(c);
  string ans = "No";
  for (int i = 1; i * i <= d; i++) {
    if (i * i == d) ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=1e5+3;
int n,lg2,f[mn],gra,beg[mn],to[mn*2],nex[mn*2];
void ins(int u,int v){
	to[++gra]=v;
	nex[gra]=beg[u];
	beg[u]=gra;
}
void dfs(int p,int q){
	int tmp=0;
	fr(i,p)if(to[i]!=q){
		dfs(to[i],p);
		tmp|=f[p]&f[to[i]];
		f[p]|=f[to[i]];
	}
	int lim=0;
	fd(i,lg2,0)if(tmp&(1<<i)){lim=i+1;break;}
	fo(i,lim,lg2)if(!(f[p]&(1<<i)))
		{f[p]=((f[p]>>i)+1)<<i;return;}
}
int main(){
	scanf("%d",&n);
	fo(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		ins(u,v);
		ins(v,u);
	}
	lg2=log(n)/log(2)+1;
	dfs(1,0);
	fd(i,lg2,0)if(f[1]&(1<<i)){printf("%d",i);return 0;}
	return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 200010;

ll sum = 0, xr = 0;
int a[N], nxt[N], n;

int main() 
{
	n = read();
	rep(i, 1, n) a[i] = read();
	ll ans = 0;
    rrep(i, n, 1)
    {
        nxt[i] = nxt[i + 1];
        if (a[i + 1]) nxt[i] = i + 1;
    }
    rep(i, 1, n)
    {
        sum = xr = a[i];
        int cur = i;
        while (nxt[cur]) 
        {
            if (sum + a[nxt[cur]] == (xr ^ (a[nxt[cur]]))) 
            {
                cur = nxt[cur];
                sum += a[cur];
                xr ^= a[cur];
            } else break;
        }
        if (nxt[cur]) ans += nxt[cur] - i;
        else ans += n - i + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
S = list(int(input()) for i in range(n))

ans = sum(S)
sort_S = sorted(S)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for s in sort_S:
        if s % 10 != 0:
            ans -= s
            print(ans)
            exit()
print(0)

Measured memory_bytes: 8972
#include <cstdio>
#include <cctype>
using namespace std;

int main() {
	char c;
	int num[26] = {0};
	while(scanf("%c", &c) != EOF){
		if(isalpha(c)){
			c = tolower(c);
			++num[c - 'a'];
		}
	}
	for(int i = 0; i < 26; ++i){
		printf("%c : %d\n", 'a' + i, num[i]);
	}
	return 0;
}

Measured memory_bytes: 980
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var H = cin.scanint;

        long ans = 0;
        for (int i = 0; i < H.Max(); i++)
        {
            bool flag = true;
            for (int j = 0; j < N; j++)
            {
                if (H[j] <= i)
                {
                    if (!flag)
                    {
                        flag = true;
                    }
                }
                else
                {
                    if (flag)
                    {
                        ans++;
                        flag = false;
                    }
                }
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define dump(x) cout << #x << " = " << x << endl

using namespace std;

int h, w;
char maze[20][20];
int reach[20][20];
pair<int, int> st;

void disp(){
	rep(i,0,h){
		rep(j,0,w) cout << maze[i][j];
		cout << endl;
	}
	cout << endl;

	rep(i,0,h){
		rep(j,0,w) cout << reach[i][j];
		cout << endl;
	}
	cout << endl;
}

int dr[4] = {0, -1, 0, 1};
int dc[4] = {-1, 0, 1, 0};

void dfs(int r, int c){
	if(r<0 or r>h-1 or c<0 or c>w-1) return ;
	if(maze[r][c] == '#' or reach[r][c] == 1) return ;

	reach[r][c] = 1;
	rep(i,0,4){
		dfs(r+dr[i], c+dc[i]);
	}
	return;
}

void solve(){
	int ans=0;

	rep(i,0,h) rep(j,0,w){
		if(reach[i][j] == 1) ans++;
	}
	cout << ans << endl;
	return;
}

int main(){

	while(1){
		cin >> w >> h;
		if(h == 0) break;

		rep(i,0,h) rep(j,0,w){
			cin >> maze[i][j];
			reach[i][j] = 0;
			if(maze[i][j] == '@'){
				st.first = i;
				st.second = j;
			}
		}
		dfs(st.first, st.second);
		solve();
	}


	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, l;cin >> n >> l;
	vector<string> v(n);string s;
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());
	rep(i, n) s += v[i];
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b=0;
    cin>>a;
    char c[a];
    for(int i=0;i<a;i++) cin>>c[i];
    for(int i=0;i<a;i++){
        if(c[i]=='Y') b++;
    }
    if(b>0) cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

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

    int dp[s.length()][t.length()];
    memset(dp, 0, sizeof(dp));

    for (int i = 1; i < s.length(); i++) {
        for (int j = 1; j < t.length(); j++) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    string ans;
    int y, x;
    y = s.length() - 1;
    x = t.length() - 1;

    while (y > 0 && x > 0) {
        if (dp[y][x] == dp[y - 1][x]) {
            y--;
        } else if (dp[y][x] == dp[y][x - 1]) {
            x--;
        } else {
            ans.push_back(s[y]);
            y--;
            x--;
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}

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

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

    vector<vector<int>> graph(n);
    for(int i=0; i<n; i++){
        string s;
        cin >> s;

        for(int j=0; j<n; j++){
            if(s[j] == '1') graph[i].push_back(j);
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        vector<int> d(n);
        d[i] = 1;

        queue<int> q;
        q.push(i);

        while(q.empty() == false){
            int node = q.front();
            q.pop();
            ans = max(ans, d[node]);

            for(int adjacent : graph[node]){
                if(d[adjacent] == 0){
                    d[adjacent] = d[node] + 1;
                    q.push(adjacent);
                }
                else{
                    if(abs(d[adjacent] - d[node]) != 1){
                        cout << -1 << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3812
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [list(map(int,input().split())) for _ in range(M)]
ans = min(a)+min(b)
for i in l:
    ans = min(ans,a[i[0]-1]+b[i[1]-1]-i[2])
print(ans)

Measured memory_bytes: 38440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

int main(){	
	string S;
	long long K;
	cin >> S;
	scanf("%lld",&K);
	bool same = true;
	ll N = S.length();
	rep(i, N-1) {
		if (S[i] != S[i+1]) same = false;
	}
	if (same) {
		cout << N*K/2 << endl;
		return 0;
	}
	if (S[0] != S[N-1]) {
		ll c = 0;
		rep(i, N-1) {
			if (S[i] == S[i+1]) {
				c++;
				i++;
			}
		}
		cout << c*K << endl;
		return 0;
	} else {
		ll s = 0, e = N-1, c = 0;
		while(S[s] == S[s+1]) s++;
		while(S[e] == S[e-1]) e--;
		for(ll i = s+1; i < e-1; i++) {
			if (S[i] == S[i+1]) {
				c++;
				i++;
			}
		}
		// cout << c << " " << s << " " << e << endl;
		cout << c*K+(((N-e)+(s+1))/2)*(K-1)+((s+1)/2)+((N-e)/2) << endl;
		return 0;
	}
	return 0;
}



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

int main()
{
  int n;
  cin>>n;
  vector<pair<int,int> > arr(n);
  for(int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    arr[i] = make_pair(a,i+1);
  }
  sort(arr.begin(),arr.end());
  for(int i=0;i<n;i++)
    cout<<arr[i].second<<" ";
  return 0;
}


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

const int MAX_N=200005;
int H[MAX_N];
int main() {
  int n, k; cin >> n >> k;
  long long ans = 0;
  for(int i=0; i<n; i++) cin >> H[i];
  sort(H, H+n);
  
  for(int i=0; i<max(0, n-k); i++)
    ans += H[i];
  
  cout << ans << endl;
  
  return 0;
}

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

int main(void)
{
	map<string, int> gacha_keihin;
    
    int N;
    cin >> N;
  
    for(int i = 0; i < N; i++)
    {
        string keihin_name;
        cin >> keihin_name;
        gacha_keihin.insert( make_pair(keihin_name, 1) );
    }
    cout << gacha_keihin.size() << endl;
    return 0;
}


Measured memory_bytes: 19192
from collections import deque
n, x = map(int, input().split())
*a, = map(int, input().split())
a = deque(a)
a.appendleft(0)
a.append(0)
ans = 0

for k in range(1, n+1):
    s = a[k-1]+a[k]-x
    if s > 0:
        a[k] -= s
        ans += s

print(ans)


Measured memory_bytes: 14516
n = int(input())
a = sorted([int(input()) for _ in range(n)])
ans = 0
tmp = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        if tmp % 2 == 1:
            ans += 1
        tmp = 1
if tmp % 2 == 1:
    ans += 1
print(ans)

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

int deg[100001];
int max_deg;
vector<int> T[100001];
int used[100001];
vector<int> leaves;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		T[u].push_back(v);
		T[v].push_back(u);
	}
	for (int i = 0; i < n; i++)
	{
		if (T[i].size() == 1)
			leaves.push_back(i);
		max_deg = max(max_deg, (int)T[i].size());
	}

	if (max_deg <= 2) // is_chain
	{
		cout << 1 << endl;
		exit(0);
	}

	int ans = leaves.size();
	queue<int> q;
	for (int i = 0; i < leaves.size(); i++)
	{
		while (!q.empty())
		{
			q.pop();
		}
		int s = leaves[i];
		used[s] = true;
		q.push(s);
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			used[u] = true;
			if (T[u].size() >= 3)
			{
				ans--;
				break;
			}
			for (int j = 0; j < T[u].size(); j++)
			{
				int v = T[u][j];
				if (!used[v])
				{
					q.push(v);
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 7164
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	scanf("%d",&n);
	printf("%d\n",(n-2)*180);
	return 0;
}
/*
input:
*/


Measured memory_bytes: 256
s = int(input())
count = 1
tmp = [s]
res = 0
while True:
    if s%2==1:
        s = s*3+1
    else:
        s = s//2
    count += 1
    if s in tmp:
        res = count
        break
    else:
        tmp.append(s)
print(res)
    

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

int main(){
    vector<ll> a(7);
    for(int i=0;i<7;i++){
        cin >> a[i];
    }
    ll k = min(a[0], min(a[3], a[4]));
    ll ans = k * 3 + ((a[0]-k) / 2) * 2 + a[1] + ((a[3]-k) / 2) * 2 + ((a[4]-k) / 2) * 2;
    if(k > 0){
        k--;
        ans = max(ans, k * 3 + ((a[0]-k) / 2) * 2 + a[1] + ((a[3]-k) / 2) * 2 + ((a[4]-k) / 2) * 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define inpv(a,n) vector<ll> a(n); for(ll i=0;i<n;i++){cin>>a[i];}
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define iniv(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);
ll mod=MOD;

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
int main() 
{
	// #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
	fio;
	ll testcase=1;
	//cin>>testcase;
	while(testcase--)
	{
		string s,t;
		cin>>s>>t;
		ll len=t.length();
		forin(i,0,s.length()-t.length())
		{
			ll p=0;
			forin(j,0,t.length()-1)
			{
				if(t[j]!=s[i+j])
				{
					p++;
				}
			}
			len=min(len,p);
		}
		ol(len);
	}
}

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

int a()
{
    int a, b;
    std::cin >> a >> b;
    
    
    
    std::cout << a * b << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}

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

using namespace std;

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

	int n, k;
	cin >> n >> k;

	vector<int> p;
	p.resize(n);

	for(int &i : p) {
		cin >> i;
	}

	set<int> s;

	for(int i = 0; i < k; ++i) {
		s.emplace(p[i]);
	}

	int ans = 1;

	for(int i = 0; i + k < n; ++i) {
		bool f1 = (*s.begin() == p[i]);
		s.emplace(p[i + k]);
		s.erase(p[i]);
		bool f2 = (*s.rbegin() == p[i + k]);

		if(!f1 || !f2) {
			++ans;
		}
	}

	bool ok = false;

	int pre = -1;
	int cnt = 0;

	for(int i = 0; i < n; ++i) {
		if(pre < p[i]) {
			++cnt;
		} else {
			cnt = 1;
		}

		pre = p[i];

		if(cnt == k) {
			--ans;
			ok = true;
		}
	}

	cout << ans + ok << '\n';

	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
        ll N;
        cin>>N;
        ll res=0;
        for(ll i=0;i*i<=1e18;i++){
                if(i*i>N){
                        res=(i-1)*(i-1);
                        break;
                }
        }
        cout<<res<<endl;
        return 0;
}


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

#define STACK_SIZE 20000  /* スタックデータ数の最大値 */

typedef struct stack1 {
    int index;
    char slope;
} Stack1;

typedef struct stack2 {
    int index;
    int subtotal;
} Stack2;

Stack1 stack1[STACK_SIZE];
Stack2 stack2[STACK_SIZE];
Stack2 subtotal[STACK_SIZE];
int top1, top2, subtotal_top;
 
void push1(int _index, char _slope){
    stack1[++top1].index = _index;
    stack1[top1].slope = _slope;
}

void push2(int _index, int _subtotal){
    stack2[++top2].index = _index;
    stack2[top2].subtotal = _subtotal;
}

void push_subtotal(int _index, int _subtotal) {
    subtotal[++subtotal_top].index = _index;
    subtotal[subtotal_top].subtotal = _subtotal;
}

Stack1 pop1(){
    top1--;
    return stack1[top1 + 1];
}

Stack2 pop2(){
    top2--;
    return stack2[top2 + 1];
}

Stack2 pop_subtotal(){
    subtotal_top--;
    return subtotal[subtotal_top + 1];
}

int main(void)
{
    int i, sum, subtotal;
    top1 = -1;
    top2 = -1;
    subtotal_top = -1;
    char input[STACK_SIZE];

    i = 0;
    sum = 0;
    subtotal = 0;

    scanf("%s", input);
    
    while(input[i] != '\0'){
        if (input[i] == '\\'){
            push1(i, input[i]); // stack1にiをpush
        } else if (input[i] == '/') {
            while(top1 >= 0) {
                Stack1 stack1_top = pop1();
                if (stack1_top.slope == '\\') {
                    sum += (i - stack1_top.index);
                    push2(stack1_top.index, i - stack1_top.index);

                    break;
                }
                
            }
        }
        i++;
    }
    
    int j = 0;

    if (top2 >= 0) {
        Stack2 tmp = pop2();
        int min_index = tmp.index;
        subtotal = tmp.subtotal;

        while (top2 >= 0) {
            Stack2 stack2 = pop2();

            if (min_index > stack2.index) {
                push_subtotal(min_index, subtotal);
                subtotal = 0;
                min_index = stack2.index;
                subtotal = stack2.subtotal;
            } else if (min_index < stack2.index) {
                subtotal += stack2.subtotal;
            }
        }
        push_subtotal(min_index, subtotal);
    }
    
    printf("%d\n", sum);
    printf("%d", subtotal_top + 1);
     while (subtotal_top >= 0) {
        if (subtotal_top >= 0) printf(" ");
        Stack2 output_subtotal = pop_subtotal();
        printf("%d", output_subtotal.subtotal);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);
            int k = int.Parse(temp[3]);

            if(k <= a)
            {
                Console.WriteLine(k);
            }
            else if(k <= a + b)
            {
                Console.WriteLine(a);
            }
            else if(k <= a + b + c)
            {
                Console.WriteLine(a - (k - a - b));
            }

        }
    }
}


Measured memory_bytes: 27420
N = int(input())
b = input().split()
a = [int(n) for n in b]

c = 0
flag = 1
while flag:
    flag = 0
    for j in range(1,N):
        if a[j] < a[j-1]:
            v = a[j]
            a[j] = a[j-1]
            a[j-1] = v
            c +=1
            flag =1
print(" ".join([str(n) for n in a]))
print(c)


Measured memory_bytes: 5608
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        if random.randint(0,1):           
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
                ans[d3] = tmp3
            else:
                ans[d1] = tmp1
                ans[d2] = tmp3
                ans[d3] = tmp2
                  
        else:
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <assert.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// ARC016-A, 993, 
	string s; cin >> s;
	int ss = s.size();
	int ans = iINF;
	rep(i, 26) {
		char cur = 'a' + i;
		vector<int> pos;
		pos.push_back(-1);
		rep(j, ss) {
			if (s[j] == cur) pos.push_back(j);
		}
		if (pos.size() == 1) continue;
		pos.push_back(ss);
		int tmpans = 0;
		rep(j, pos.size() - 1) tmpans = max(tmpans, pos[j + 1] - pos[j] - 1);
		ans = min(ans, tmpans);
	}
	cout << ans << endl;
	return 0;
}

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

from itertools import product
N = int(input())
A = {}
for i in range(N):
    A[i] = []

for i in range(N):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        A[i].append([x-1, y])

ret = -1
for p in product([0,1], repeat=N):
    cnt = 0
    flag = True
    for i in range(N):
        if p[i] == 1:
            for XY in A[i]:
                if XY[1] != p[XY[0]]:
                    flag = False
    if flag:
        ret = max(sum(p), ret)


print(ret)


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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	bool can = true;
	int lt = 0,lx = 0,ly = 0;
	for(int i = 0;i < n;i++){
		int t,x,y;
		cin >> t >> x >> y;
		int dt = t - lt;
		int dx = abs(lx - x);
		int dy = abs(ly - y);
		
		if((dx + dy) > dt){
			can = false;
		}else{
			if((dt - dx - dy) % 2 == 1){
				can = false;
			}
		}
	}
	
	if(can){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    ll s = accumulate(v.begin(), v.end(), 0);
    ll temp = 4 * m;
    ll t = (s + temp - 1) / temp;
    ll count = 0;

    // cout << s << " " << t << endl;

    for (int i = 0; i < n; i++)
    {
        if (v[i] >= t)
        {
            count++;
            if (count == m)
            {
                break;
            }
        }
    }

    // cout << count << endl;

    if (count == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

inf = float('inf')
n, m, r = map(int, input().split())  # 町数、道数、訪問地数
t = tuple(int(x) - 1 for x in input().split())  # 訪問地
g = [[inf] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j] = min(g[i][j], g[i][k] + g[k][j])

ans = inf
for p in permutations(t):
    ans = min(ans, sum(g[a][b] for a, b in zip(p, p[1:])))
print(ans)


Measured memory_bytes: 73944
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int n, k;
	cin >> n >> k;
	int arr[n+1];
	arr[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i+1];
		arr[i+1] += arr[i];
	}
	int ans = 0;
	for (int i = k; i <= n; ++i)
	{
		ans = max(ans, arr[i] - arr[i-k]);
	}
	cout << fixed << setprecision(9) << (double)(ans+k)/2.0;

	return 0;
}

Measured memory_bytes: 1024
import math


def get_theta(H, M):
    M_theta = math.pi / 30 * M
    H_theta = math.pi / 6 * (H + M / 60)

    return min(abs(M_theta - H_theta), 2 * math.pi - abs(M_theta - H_theta))

A,B,H,M = [int(s) for s in input().split()]

theta = get_theta(H, M)
print(((B*math.cos(theta) - A)**2 + (B*math.sin(theta))**2)**0.5)

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X,Y);
    swap(X,Z);
    cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 256
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()
s=set(map(int,input().split()))
ans=10**9
for i in range(101):
    if not X-i in s:
        print(X-i)
        exit()
    if not X+i in s:
        print(X+i)
        exit()

Measured memory_bytes: 9160
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     int n;
  cin >> n;
  ll ans = 0;
  int i,j;
  for(i=1;i<=n;i++)
  {
    ll to = n/i;
    ans += to*(to+1)/2*i;
  }
  cout << ans << "\n";
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X; cin >> X;
  if(X<100){ cout << 0; return 0;}
  int p = X/100;
  int q = X%100;
  
  if(q%5==0){
    if(p>=(q/5)){
      cout << 1; return 0;
    }else{
      cout << 0; return 0;
    }
  }
  if(p>=1+(q/5)){
    cout << 1; return 0;
  }else{
    cout << 0; return 0;
  }

}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='o') cnt++;
  }
  cout << 700+100*cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<int,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
  int k; cin >> k;
  string ans="";
  rep(i,k){
    ans+="ACL";
  }
  cout << ans << endl;
  return 0;
}


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

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

int main() {
	int n;
	cin >> n;
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	rep(i, n) {
		string s;
		cin >> s;
		if (s == "AC") a++;
		if (s == "WA") b++;
		if (s == "TLE") c++;
		if (s == "RE") d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	return 0;
}



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

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  // array<int, 10000> A;
  // string S;
  // string T;

  int A, B, C;

  cin >> A >> B >>C;

  if (A == B) cout << C << endl;
  else if (B == C) cout << A << endl;
  else cout <<B << endl;
  
  
  // cin >> N;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;
  // cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int a[101]={0};
int main()
{
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++)
	{
		if(a[i]==1)s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            int c = 0, s = 0, p = 0;
            for (string i; (i = Console.ReadLine()) != null; ++c) {
                var v = Array.ConvertAll(i.Split(','), int.Parse);
                s += v[0] * v[1];
                p += v[1];
            }
            Console.WriteLine(s);
            Console.WriteLine((int)((double)p / c + 0.5));
        }
    }
}

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

int main()
{
    ll N;
    string S;
    ll Rcount = 0;
    ll Gcount = 0;
    ll Bcount = 0;
    ll continueCount = 0;
    cin >> N >> S;

    for(ll i = 0; i < N; i++)
    {
        if(S[i] == 'R')Rcount++;
        if(S[i] == 'G')Gcount++;
        if(S[i] == 'B')Bcount++;
        for(ll j = 1; 2 * j + 1 <= N; j++)
        {
            if(i + 2 * j < N)
            {
                if(S[i] != S[i+j] && S[i+j] != S[i+2*j] && S[i] != S[i+2*j])
                {
                    continueCount++;
                }
            }
        }
        
    }

    cout << Rcount * Gcount * Bcount - continueCount << endl;
}

Measured memory_bytes: 3632
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    x1, y1, x2, y2 = MII()
    a = x2 - x1
    b = y2 - y1
    x3 = x2 - b
    y3 = y2 + a
    x4 = x1 - b
    y4 = y1 + a
    print(x3, y3, x4, y4)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int n,t[100],m,p[100],x[100],sum=0;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n;
  REP(i,n)cin>>t[i];
  REP(i,n)sum+=t[i];
  // P(sum);
  cin>>m;
  REP(i,m)cin>>p[i]>>x[i];
  REP(i,m){
    // P(t[p[i]-1]);
    P(sum-t[p[i]-1]+x[i]);
  }
  return 0;
}


Measured memory_bytes: 256