akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=505,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n;
int c[MAXn][MAXn];
int in[MAXn][MAXn];
int dx[] = {1,0,0,-1};
int dy[] = {0,1,-1,0};
bool chk(int x,int y){
    return x < 0 || x >= n || y < 0 || y >= n;
}
void dfs(int x,int y){
    int tmp = c[x][y] + in[x][y];
    REP (i,4) {
        int tx = x + dx[i], ty = y + dy[i];
        if (chk(tx,ty)) continue;
        if (c[tx][ty] > tmp) {
             c[tx][ty] = tmp;
             dfs(tx,ty);
        }
    }
}
int main(){
    IOS();
    cin >> n;
    REP (i,n) REP (j,n) {
        c[i][j] = min({i,j,n-i-1,n-j-1});
        in[i][j] = 1;
        debug(i,j,c[i][j]);
    }
    int ans = 0;
    REP (i,n*n) {
        int cur;
        cin >> cur;
        cur--;
        int x = cur/n, y = cur%n;
        ans += c[x][y];
        in[x][y] = 0;
        dfs(x,y);
        debug(ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 21052
def main():
    D = int(input())
    c = list(map(int, input().split()))
    last = [0] * 27
    for d in range(0, D):
        s = list(map(int, input().split()))
        max_s = max(s)
        index_s = s.index(max_s)
        print(26)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9012
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/
#include<bits/stdc++.h>
#define mem(a) memset(a,0,sizeof(a))
#define INF 0x3f3f3f3f
#define Min 1e-6
#define lowbit(x) ((x)&(-x))
#define ls rt<<1
#define rs rt<<1|1
#define ll int

using namespace std;

const int N = 2e5 + 7;
const int M = 1e9 + 7;
const ll Mod = 1e9 + 7;

int i,j,n,m,t,T,p,l,r,q,len,len1,v,u,k,w,st,res,cnt,ans,tmp,nex,a[N];
string s;

int main()
{
    ios::sync_with_stdio(false);
    mem(a);
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll cnt = 0;
    map<ll, bool> f;
    rep(i,n){
        if(f[a[i]]==false){
            if(mp[a[i]]%2==1)
                cnt++;
            f[a[i]] = true;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 13568
h,w = map(int,input().split(" "))
if h == 1 or w == 1:
    print(1)
    exit()
if h % 2 == 0:
    print((h // 2) * w)
else:
    if w % 2 == 0:
        print((h // 2) * w + (w // 2))
    else:
        print((h // 2) * w + (w // 2) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

vector<ll> a = {0, 26, 702, 18278, 475254, 12356630, 321272406, 8353082582, 217180147158, 5646683826134, 146813779479510, 3817158266467286, 99246114928149456};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n;
  cin >> n;
  ll x = ceil(log(25*n+26)/log(26))-1;
  n -= a[x-1];
  
  for(ll i = x-1; i >= 0; i--) {
    ll q = (n-1)/pow(26, i) + 1;
    n -= pow(26, i)*(q-1);
    cout << (char)('a'+q-1);
  }
  cout << "\n";
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int a, b, c, d, e, f;
int xx, yy;

bool check(int x, int y)
{
	bool flag = false;
	for (int i = 0; i * 100 * a <= x; i ++ )
		for (int j = 0; j * 100 * b <= x - i * 100 * a; j ++ )
			if (!flag && i * a * 100 + j * b * 100 == x)
			{
				flag = true;
				break;
			}
	if (!flag) return false;
	
	flag = false;
	for (int i = 0; i * c <= y; i ++ )
		for (int j = 0; j * d <= y - i; j ++ )
			if (!flag && i * c + j * d == y)
			{
				flag = true;
				break;
			}
	return flag;
}

int main()
{
	cin >> a >> b >> c >> d >> e >> f;
	
	double res = -1;
	for (int x = 0; x <= f / 100; x ++ )
		for (int y = 0; y <= x * e; y ++ )
			if (x * 100 + y <= f && check(100 * x, y))
				if (res < (double)y / (100.0 * x + (double)y))
				{
					res = (double)y / (100.0 * x + (double)y);
					xx = x, yy = y;
				}
				
	cout << xx * 100 + yy << ' ' << yy << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
using namespace std; 
int a[100010];
int z[100010];
int main(){
    int n,m; cin >> n >> m;
    int p;
    int ac=0;
    int wa=0;
    string s;
    for (int i = 0;i < m;i++){
        cin >> p >> s;
        if (s=="AC" && z[p-1]==0){
            ac+=1;
            z[p-1]=1;
            wa+=a[p-1];
        }
        else if (s=="WA"){
            a[p-1]+=1;
        }
    }
    cout << ac << " " << wa << "\n";
}


    

  


    

  


  


Measured memory_bytes: 1024
n, m = map(int, input().split())
listA = [list(map(int,input().split())) for i in range(n)]
listB = [int(input()) for j in range(m)]

for j in range(n):
    sum = 0
    for i in range(m):
        sum += listA[j][i] * listB[i]
    print(sum)



Measured memory_bytes: 5976
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        // 数値の取得
        Scanner scn = new Scanner(System.in);
        int i = scn.nextInt();
        scn.close();
        
        //一の位の取得
        int x = i % 10;
        
        //一の位に応じた分岐
        if(x == 3) {
            System.out.println("bon");
        } else if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
            System.out.println("hon");
        } else {
            System.out.println("pon");
        }
    }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int a; cin>>a;
	int ans=a+a*a+a*a*a;
	cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 55;
int N, K;
long long V[MAX_N];

long long calc(int L, int R) {
    std::vector<long long> get;

    //std::cout << L << " " << R << std::endl;

    for (int i = 1; i <= L; i++) {
        get.push_back(V[i]);
    }

    for (int i = N; N - R + 1 <= i; i--) {
        get.push_back(V[i]);
    }

    std::sort(get.begin(), get.end(), std::greater<long long>());

    //for (long long v : get) {
    //    std::cout << v << " ";
    //}
    //std::cout << std::endl;

    for (int i = 0; i < K - L - R; i++) {
        if (get.size() == 0) {
            break;
        }
        if (get.back() < 0) {
            get.pop_back();
        } else {
            break;
        }
    }

    long long ret = 0;
    for (long long v : get) {
        ret += v;
    }

    return ret;

}

int main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> V[i];
    }

    long long ret = 0;
    for (int i = 0; i <= std::min(N, K); i++) {
        for (int j = 0; i + j <= std::min(N, K); j++) {
            ret = std::max(ret, calc(i, j));
        }
    }

    std::cout << ret << std::endl;

    

    return 0;
}


Measured memory_bytes: 256
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#define int long long
using namespace std;
int k,dt[101010];
deque<int>q;
signed main()
{
	cin>>k;
	for(int i=0;i<k+100;i++)
	{
		dt[i]=1e9;
	}
	q.push_back(1);
	dt[1]=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop_front();
		int a=x*10;
		a%=k;
		if(dt[a]>dt[x])
		{
			q.push_front(a);
			dt[a]=dt[x];
		}
		a=x+1;
		a%=k;
		if(dt[a]>dt[x]+1)
		{
			q.push_back(a);
			dt[a]=dt[x]+1;
		}
	}
	cout<<dt[0]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

class edge
{
public:
	int to;
	int cost;

	edge(int _to,int _cost)
	{
		this->to=_to;
		this->cost=_cost;
	}
};

int d[30];
vector<edge> G[30];

int n,m;

int dijkstra(int s,int t)
{
	priority_queue<P,vector<P> , greater<P> > que;
	fill(d,d+30,INF);
	d[s]=0;
	que.push(P(0,s));

	while(que.size())
	{
		P p=que.top();
		que.pop();

		if(p.sc==t) return d[t];

		rep(i,G[p.sc].size())
		{
			edge e=G[p.sc][i];
			if(d[e.to] > d[p.sc]+e.cost)
			{
				d[e.to]=d[p.sc]+e.cost;
				que.push(P(d[e.to],e.to));
			}

		}

	}

}

int main()
{
	cin>>n>>m;
	int a,b,c,d;
	rep(i,m)
	{
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		G[a].pb(edge(b,c));
		G[b].pb(edge(a,d));
	}
	scanf("%d,%d,%d,%d",&a,&b,&c,&d);

	printf("%d\n",c-d-dijkstra(a,b)-dijkstra(b,a));



		return 0;
}

Measured memory_bytes: 1228
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var av = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var b = long.Parse(line[0]);
        var bv = long.Parse(line[1]);
        var t = long.Parse(Console.ReadLine().Trim());
        Console.WriteLine(getAns(a, av, b, bv, t));
    }
    static string getAns(long a, long av, long b, long bv, long t)
    {
        if (a > b) return getAns(-a, av, -b, bv, t);
        return a + av * t >= b + bv * t ? "YES" : "NO";
    }
}


Measured memory_bytes: 27500
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = a*b;
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 25340
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
    string s = readln.chomp;

    int ans = 0;
    foreach (e; s) {
        if (e == '+') {
            ans += 1;
        }
        else if (e == '-') {
            ans -= 1;
        }
    }

    writeln(ans);
}

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

using namespace std;
     
int main(){
    int X,ans=0;
    vector<int> S;
    cin >> X;

    for(int i=1;i<X;i++){
        for(int j=2;j<1000;j++){
            ans = pow(i,j);
            if(ans > X){
                if(j==2) break;
                ans = pow(i,j-1);
                S.push_back(ans);
                break;
            }
        }
    }

    cout << (X==1 ? 1 : *max_element(S.begin(),S.end())) << endl;
    
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] a = new int[m];
		int[] b = new int[m];
		int[] cnt = new int[n];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;

			cnt[a[i]]++;
			cnt[b[i]]++;
		}

		for (int i = 0; i < n; i++) {
			pr.println(cnt[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b<24)cout << a+b << endl;
    else cout << a+b-24 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W; cin >> H >> W;
  vector<string> vs(H);
  FOR(i,0,H) cin >> vs[i];
  int vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
  int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  FOR(h,0,H) {
    FOR(w,0,W) {
      if(vs[h][w] == '.') {
        int cnt = 0;
        FOR(i,0,8) {
          int y = h + vy[i];
          int x = w + vx[i];
          if(y >= 0 && y < H && x >= 0 && x < W && vs[y][x] == '#') cnt++;
        }
        vs[h][w] = char('0' + cnt);
      }
    }
  }
  FOR(i,0,H) cout << vs[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int yes;
    int ren[100005];
    for(int i=1;i<=n;i++)
        ren[i]=k;
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&yes);
        ren[yes]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(ren[i]<=q)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1024
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){c=i.split(' ');if(c[2])console.log(((c[3]-c[1])/(c[2]-c[0])).toFixed(6)==((c[7]-c[5])/(c[6]-c[4])).toFixed(6)?'YES':'NO')})

Measured memory_bytes: 7908
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > ans;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int N, K;
	cin >> N >> K;
	
	VI X(N), Y(N), C(N);
	REP(i, N) {
		char c;
		cin >> X[i] >> Y[i] >> c;
		X[i] %= K * 2;
		Y[i] %= K * 2;
		C[i] = (c == 'W');
	}
	int white[2010][2010] = { 0 };

	int bnum = 0;

	REP(i, N) {
		C[i] += X[i] / K + Y[i] / K;
		C[i] %= 2;
		X[i] %= K;
		Y[i] %= K;
		white[X[i]][Y[i]] += (C[i] ? 1 : -1);
		if (C[i] == 0)bnum++;
	}
	REP(x, K) {
		FOR(y, 1, K) {
			white[x][y] += white[x][y - 1];
		}
	}
	
	FOR(x, 1, K) {
		REP(y, K) {
			white[x][y] += white[x - 1][y];
		}
	}

	int ans = 0;
	REP(x, K) {
		REP(y, K) {

			int w = white[K - 1][K - 1] - white[x][K - 1] - white[K - 1][y] + white[x][y] * 2 + bnum;
			ans = max(ans, max(w, N - w));
		}
	}

	cout << ans << endl;

	return 0;

}





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

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

using namespace std;

int main() {
  int x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  int x3 = x2 - (y2 - y1);
  int y3 = y2 + (x2 - x1);
  int x4 = x3 - (y3 - y2);
  int y4 = y3 + (x3 - x2) ;

  std::cout << x3 << " " << y3  << " " << x4 << " " << y4 << std::endl;

  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    while (b != 0) {
        ll x = a, y = b;
        a = y, b = x % y;
    }
    return a;
}

int main()
{
    ll n; cin >> n;
    ll lcm = 1;
    rep(i, n) {
        ll num; cin >> num;
        lcm = lcm / gcd(lcm, num) * num;
    }
    cout << lcm << endl;

    return 0;
}

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

class Rank {
public:
  Rank() {}
  Rank(int s, int ti, int te) : s(s), ti(ti), te(te) {}
  int s, ti, te;
};
bool comp (const Rank &r1, const Rank &r2) {
  if(r1.s == r2.s && r1.s == 0) return r1.te < r2.te;
  return r1.s!=r2.s ? r1.s<r2.s : (r1.ti!=r2.ti ? r1.ti<r2.ti : r1.te<r2.te);
}

int main() {
  int m, t, p, j;
  int M, T, P, R;
  vector<Rank> rank;
  while(cin >> M >> T >> P >> R && M+T+P+R) {
    rank.clear();
    int penal[55][12];
    bool solved[55][12];

    fill(penal[0], penal[52], 0);
    fill(solved[0], solved[52], 0);

    for(int ii = 0; ii < R; ii++) {
      cin >> m >> t >> p >> j;
      p--; t--;
      if(j != 0) penal[t][p] += 20;
      else penal[t][p] += m, solved[t][p] = true;
    }
    for(int i=0; i<T; i++) {
      int sum = 0;
      for(int j=0; j<P;j++) {
	if(solved[i][j]) sum += penal[i][j];
      }
      int ssum = 0;
      for(int j=0; j<P; j++) {
	ssum += solved[i][j];
      }
      rank.push_back(Rank(-ssum, sum,-i-1));
    }
    sort(rank.begin(), rank.end(), comp);
    
    bool flag = 0;
    for(int i=0; i<rank.size(); i++) {
      if(flag && rank[i-1].s == rank[i].s && rank[i-1].ti == rank[i].ti) cout << "=";
      else if(flag) cout << ",";
      cout << -rank[i].te;
      flag = 1;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 1005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct tree{
	int p;
	vector<int> c;
	int x,y;
};

int N;
tree T[SIZE];
P R[SIZE];

void dfs(int v,int r){
	R[v].first = r;
	R[v].second = v;
	for(auto c : T[v].c) dfs(c,r+1);
}

int main()
{
	cin >> N;
	rep(i,2,N+1){
		int p;
		cin >> p;
		T[i].p = p;
		T[p].c.push_back(i);
	}
	dfs(1,0);
	rep(i,1,N+1){
		int x;
		cin >> x;
		T[i].x = x;
	}
	sort(R+1,R+N+1,greater<P>());

	bool U = true;
	rep(i,1,N+1){
		vector<int> dp;
		int v = R[i].second;
		if(T[v].c.size() == 0){
			T[v].y = 0;
			continue;
		}
		int sum = 0;
		dp.push_back(0);
		for(auto c : T[v].c){
			int X = T[c].x;
			int Y = T[c].y;
			sum += X+Y;
			vector<int> DP;
			for(auto k : dp){
				if(X+k <= T[v].x)DP.push_back(X+k);
				if(Y+k <= T[v].x)DP.push_back(Y+k);
			}
			sort(DP.begin(),DP.end());
			DP.erase(unique(DP.begin(),DP.end()),DP.end());
			dp = DP;
		}
		if(dp.empty()){
			U = false;
			break;
		}
		if(dp[0] > T[v].x){
			U = false;
			break;
		}
		if(dp[0] == T[v].x){
			T[v].y = sum - dp[0];
			continue;
		}
		auto it = upper_bound(dp.begin(),dp.end(),T[v].x);
		--it;
		T[v].y = sum - (*it);
	}
	if(U)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 384
class Cell:
    def __init__(self, value):
        self.value = value
        self.next = None


class Stack:
    def __init__(self):
        self.top = None

    def push(self, d):
        new = Cell(d)
        new.next = self.top
        self.top = new

    def pop(self):
        if self.top is None:
            print('Stack Under Flow!!')
            return
        else:
            t = self.top.value
            p = self.top
            self.top = self.top.next
            del(p)
            return t

l = list(input().split())
st = Stack()
for i in l:
    if i == '-':
        t1 = st.pop()
        t2= st.pop()
        st.push(t2-t1)
    elif i=='*':
        t1 = st.pop()
        t2= st.pop()
        st.push(t1*t2)
    elif i == '+':
        t1 = st.pop()
        t2 = st.pop()
        st.push(t1 + t2)
    else:
        st.push(int(i))
print(st.pop())



Measured memory_bytes: 5600
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		sc.close();
		long[] b = new long[N + 1];
		b[0] = 0;
		for(int i = 0; i < N; i++) {
			b[i + 1] += b[i] + A[i];
			b[i + 1] %= M;
		}
		Map<Long, Long> map = new HashMap<Long, Long>();
		for(int i = 0; i <= N; i++) {
			map.merge(b[i], 1l, (v1, v2) -> v1 + v2);
		}
		long ans = 0;
		for(long k : map.keySet()) {
			long t = map.get(k);
			ans += t * (t - 1) / 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 63136
#include <cstdio>
const int Mod=924844033,N=2005;
int g[N<<1][N][2];bool end[N<<1];
int fac[N<<1];
inline int mo(int x){return x<Mod?x:x%Mod;}
int main (){
	int n,k;scanf ("%d%d",&n,&k);fac[0]=1;
	for (int i=1;i<=(n<<1);i++) fac[i]=1ll*fac[i-1]*i%Mod;
	for (int i=1,now=0;i<=k;i++){
		int d=(n-i)/k+1;
		end[now+=d]=true,end[now+=d]=true;
	}
	g[1][0][0]=1;
	for (int i=1;i<=(n<<1);i++)
		for (int j=0;j<=n;j++){
			g[i+1][j][0]=mo(g[i][j][0]+g[i][j][1]);
			if (!end[i]) g[i+1][j+1][1]=g[i][j][0];
		}
	int ans=0;
	for (int i=0;i<=n;i++){
		int now=1ll*fac[n-i]*(g[n+n][i][0]+g[n+n][i][1])%Mod;
		if (i&1) ans=mo(ans-now+Mod);
		else ans=mo(ans+now);
	}
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 62976
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
A = set()
for i in range(M):
    A.add(n())

dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    if i in A:
        continue
    dp[i] = dp[i-1]
    if i > 1:
        dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= 1000000007

print(dp[N])






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

/*int findlucas(int n){
    if(n==0)
    return 2;
    else if(n==1)
    return 1;
    else
    return (findlucas(n-1)+findlucas(n-2));
}*/

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int lucas[n];
    lucas[0]=2;
    lucas[1]=1;
    for(int i=2;i<=n;i++)
    lucas[i]=lucas[i-1]+lucas[i-2];
    cout<<lucas[n];
}

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


int main() {
	int n,a,b=1,c=0;
	cin>>n;
	rep(i,n){
		cin>>a;
		if(a!=b){
			c++;
		}
		else{
			b++;
		}
	}
	if(c==n){
		cout<<"-1"<<endl;
	}
	else{
		cout<<c<<endl;
	}
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 55, M = 1010, INF = 0x3f3f3f3f;

int n;
int a[N];
vector<PII> res;

int main()
{
	cin >> n;
	
	int mina = INF, axi, maxa = -INF, ini;
	for (int i = 1; i <= n; i ++ )
	{
		cin >> a[i];
		if (a[i] < mina)
		{
			mina = a[i];
			ini = i;
		}
		if (a[i] > maxa)
		{
			maxa = a[i];
			axi = i;
		}
	}
	
	if (maxa > -mina)
	{
		for (int i = 1; i <= n; i ++ ) res.PB({axi, i});
		for (int i = 1; i < n; i ++ ) res.PB({i, i + 1});
	}
	else
	{
		for (int i = 1; i <= n; i ++ ) res.PB({ini, i});
		for (int i = n; i > 1; i -- ) res.PB({i, i - 1});
	}
	
	cout << res.size() << endl;
	for (auto u : res) cout << u.F << ' ' << u.S << endl;
    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

ll powll(ll in, ll count) {
	ll reg = 1;
	for (ll i = 0; i < count; ++i)
		reg *= in;
	return reg;
}

signed main()
{
	fastio();
	vector<int> a;
	int temp;

	for (int i = 0; i < 3; i++) {
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(), a.end());
	
	cout << a[2] * 10 + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;
const long long M = 67280421310721LL;

vector<string> split(string in, char sp = ' '){
	vector<string> ret;
	stringstream ss(in);
	string s;
	while(getline(ss, s, sp)){
		ret.emplace_back(s);
	}
	return ret;
}

bool checkValidation(vector<string> sp, int ans){
	for(auto& v : sp){
		for(auto & c : v){
			if(c == 'X') c = '0' + ans;
		}
	}

	int C = 0;
	rep(i,130){
		int sum = sp[0][i] - '0' + sp[1][i] - '0';
		if((sum + C) % 10 != sp[2][i] - '0') return false;
		C = sum / 10;
	}

	return true;
}

void modmod(vector<string> sp, int s){
	range(i,s,10){
		vector<long long> a(3,0);
		rep(j,3){
			for(auto c : sp[j]){
				(a[j] *= 10) %= M;
				if(c == 'X') a[j] += i;
				else a[j] += c - '0';
			}
		}
		if((a[0] + a[1]) % M == a[2] % M){
			cout << i << endl;
			return;
		}
	}
	cout << "NA" << endl;
	return;
}

int main(){
	string s;
	while(cin >> s){
		rep(i,s.size()) if(s[i] == '+') s[i] = '=';
		vector<string> sp = split(s, '=');

		int start = 0;
		for(auto& i : sp) if(i.front() == 'X' and i.size() > 1) start = 1;
		modmod(sp, start);

		continue;
		for(auto& i : sp) reverse(all(i));
		for(auto& i : sp) while(i.size() <= 130) i.push_back('0');

		bool f = false;
		range(i,start,10){
			if(checkValidation(sp, i)){
				cout << i << endl;
				f = true;
			}
		}
		if(not f) cout << "NA" << endl;
	}
}



Measured memory_bytes: 3188
#include <iostream>
#include <assert.h>
#include <vector>
#include <stdio.h>
using namespace std;

const int NMAX = 3010;

long long dp[NMAX][NMAX];
int v[NMAX];

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

    for (int i = 1; i <= n; i++)
        cin >> v[i];

    for (int l = 1; l <= n; l++) {
        for (int i = 1; i + l - 1 <= n; i++) {
            int j = i + l - 1;
            dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]);
        }
    }

    cout << dp[1][n] << '\n';

    return 0;
}


Measured memory_bytes: 70016
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[21];
	int i, j;
	
	gets(str);
	j = strlen(str);
	
	for(i = j - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
	puts("");
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<char> s(n);
    rep(i,n) cin >> s[i];
    
    int maxv = 0;
    int x = 0;
    rep(i,n){
        if(s[i]=='I') x++;
        if(s[i]=='D') x--;
        maxv = max(x,maxv);
    }
    cout << maxv;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	string A, B;
	cin >> A >> B;

	ll N = A.size();
	ll M = B.size();

	if (N < M) { cout << "LESS"; }
	else if (N > M) { cout << "GREATER"; }
	else {
		rep(i, N) {
			if (A[i] > B[i]) { cout << "GREATER"; break; }
			if (A[i] < B[i]) { cout << "LESS"; break; }
			if (i == N - 1) { cout << "EQUAL"; }
		}
	}
	
	system("PAUSE");
}


Measured memory_bytes: 504
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll L,R;
	cin >> L>>R;
 
	// 解法
	ll ans = 0;
	ll min1 = 2018;
	ll min2 = 2018;
	if (R-L<2019){
		ll ans_tmp = 2018;
		for (ll i = L; i <= R; ++i){
			for (ll j = L; j <= R; ++j){
				if (i>=j) continue;
				if ((i*j)%2019<ans_tmp) ans_tmp = (i*j)%2019;
			}
		}
		ans = ans_tmp;
	}
	
	//出力
	cout << ans << endl;
}


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

char S[10];

int comp(const void* a, const void* b){
	if(*(char*)a-*(char*)b>0){
    	return 1;
    }else if(*(char*)a-*(char*)b == 0){
    	return 0;
    }else{
    	return -1;
    }
}

int main(void){
  	scanf("%4s", S);
  	qsort(S, 4, sizeof(char), comp);
  	if(S[0]==S[1] && S[2]==S[3] && S[1]!=S[2]){
    	printf("Yes");
    }else{
    	printf("No");
    }
  	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    char s1[15],s2[15];
    int i;
    for(i=0;i<a;i++)
        s1[i]=b+'0';
    s1[i]='\0';
    //printf ("%s\n",s1);
    for(i=0;i<b;i++)
        s2[i]=a+'0';
    s2[i]='\0';
    if(a>=b) printf("%s",s1);
    else printf ("%s",s2);
    return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

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

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

	if (n > k)
		n = n % k;
	if (n == 0)
		cout << n << endl;
	else
		cout << min(abs(n - k), n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <int,string> PIS;
typedef vector <int> vec;
#define endl '\n'
#define pi 3.141592653589793
#define fori(z,n) for(int i=z;i<n;i++)
#define forii(z,n) for(int i=z;i<=n;i++)
int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        int n;
        cin>>n;
        int arr[n];
        int c=0;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
                /* int maximum = *max_element(arr+2-1, arr+4); */
                /* cout<<maximum; */
        for(int i=1;i<n-1;i++)
        {
                int maximum = *max_element(arr+i-1, arr+i+2);
                int minimum = *min_element(arr+i-1, arr+i+2);
                if(arr[i]!=maximum && arr[i]!=minimum)
                {
                    c++;
                }
        }
        cout<<c<<endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 1000000000000000000;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    ll k;
    cin>>k;
    if(k%2==0 || k%5==0)
    {
        cout<<-1<<endl;
        return;
    }
    if(k%7==0)
    {
        k/=7;
    }
    int x=1, y=1;
    if(k==1)
    {
        cout<<1<<endl;
        return;
    }
    while(x)
    {
        x=(10*x+1)%k;
        y++;
    }
    cout<<y<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}   

Measured memory_bytes: 3808
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT() 
    H = LIST()
    ans = 0
    for i in range(N - 1):
        if H[i] > H[i + 1]:
            ans += H[i] - H[i + 1]
    ans += H[N - 1]
    print(ans)
    


if __name__ == "__main__":
    main()




Measured memory_bytes: 5200
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> a(100000);

    for(int i = 1; i <= 200; i++) {
        for(int j = 1; j <= 200; j++) {
            for(int k = 1; k <= 200; k++) {
                int x = i * i + j * j + k * k + i * j + j * k + k * i;
                if(x > N) continue;
                a[x]++;
            }
        }
    }

    for(int i = 1; i <= N; i++) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
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>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int n, q;
vector<vector<int>> g(200100);
ll c[200100];

// p: parent
void calc(int v, int p = -1)
{
  for (auto u : g[v])
  {
    if (u == p)
      continue; // 親には戻らない
    c[u] += c[v];
    calc(u, v);
  }
}

int main()
{
  cin >> n >> q;
  memset(c, 0, sizeof(c));
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i, q)
  {
    int p, x;
    cin >> p >> x;
    c[p] += x;
  }

  calc(1);

  repi(i, 1, n + 1)
  {
    cout << c[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
ll n, m, w[109], p[109], dp[109][100009];
 
ll call(ll i, ll j)
{
    if(i == n+1)
        return 0;
    if(dp[i][j])
        return dp[i][j];
    if(j + w[i] > m)
        dp[i][j] = call(i+1, j);
    else
        dp[i][j] = max(call(i+1, j), p[i] + call(i+1, j+w[i]));
    return dp[i][j];
}
 
int main()
{
    ll i, j;
    cin >> n >> m;
    for(i = 0; i < n; i++)
        cin >> w[i] >> p[i];
    cout << call(0, 0);
}
/*
4 8
2 1
3 2
4 4
5 8
*/

Measured memory_bytes: 78080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N;
	
	vector<int> v;
	
	cin >> N;
	
	bool state = true;
	
	v.push_back(0);
	v.push_back(0);
	
	int count = 0;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if((i % 2 == num) == state){
			state = !state;
			v.push_back(count);
			count = 1;
		}else{
			count++;
		}
	}
	
	v.push_back(count);
	
	int ans = 0;
	
	int len_v = v.size();
	
	for(int i = 0; i < len_v - 2; i++){
		if(ans < v[i] + v[i + 1] + v[i + 2]){
			ans = v[i] + v[i + 1] + v[i + 2];
		}
	}
	/*
	for(int i = 0; i < len_v; i++){
		cout << v[i] << " ";
	}
	*/
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r=0, l=n-1;
    int cost=0;
    for(;r<l;r++){
        if(s[r]=='W'){
            cost++;
            for(;l>r;l--){
                if(s[l]=='R'){
                    l--;
                    break;
                }
            }
            if((r==l)&&(s[l+1]!='R'))cost--;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 3744
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

S = sum(B)

for n in range(len(A)-1):
  if A[n]+1==A[n+1]:
    S += C[A[n]-1]
      
print(S)




Measured memory_bytes: 38384
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    dp = [[0,0] for _ in range(N+1)]
    dp[2] = [A[0],A[1]]
    
    for i in range(2,N):
        if (i+1)%2 ==0:
            dp[i+1][0] = dp[i-1][0]+A[i-1]
        else:
            dp[i+1][0] = max(dp[i])

        dp[i+1][1] = max(dp[i-1])+A[i]

    print(max(dp[N]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 112088
#include <iostream>
using namespace std;
int main(void){    // selectionSort
    // Your code here!
    
    int n,A[101],minj,count=0;  //nは個数
    
    cin >> n;
    
    for(int i = 0;i < n; i++){
        cin >> A[i];
        //cout << A[i] << " ";
    }
    
    
    
     // selectionSort
     for(int i = 0; i <= n-1; i++){
         minj = i;
         
         for(int j = i; j < n; j++){
             
             if(A[j] < A[minj]) minj = j;
             //cout << "minj" << A[minj] << endl;
            
         }
         
         if(A[i] != A[minj]) swap(A[i], A[minj]), count++;
         
         //cout << "A[" << i << "]" << A[i] << endl;
     }
     
     
     for(int k = 0; k < n; k++){
         if(k == n-1) cout << A[k];
         else cout << A[k] << " ";
     }
     
    cout <<endl << count << endl;
    
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int x; cin >> x;
    if(x == 3 || x == 5 || x == 7)  cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256