akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int N = in.nextInt();
        int M = in.nextInt();
        int[] aToB = in.nextInt(new int[M*2]);
        HashSet<Integer> direct = new HashSet<Integer>(); 
        HashSet<Integer> reverse = new HashSet<Integer>(); 
        for(int i=0; i<M; i++){
        	if(aToB[i*2+0]==1)
        		direct.add(aToB[i*2+1]);
        	if(aToB[i*2+1]==N)
        		reverse.add(aToB[i*2+0]);
        }
        boolean judge=false;
        for(int d: direct){
        	if(reverse.contains(d))
        		judge=true;
        }
        out.println(judge?"POSSIBLE":"IMPOSSIBLE");
        out.flush();
    }
    
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 52500
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    rep(i,n){
        if(4*m*a[i]<sum) continue;
        cnt++;
    }
    if(cnt>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
#define EQ(a,b) (abs((a)-(b))<EPS)
typedef pair<int, int > P;
const double EPS = 1e-10;

void solve()
{
	int AN, BN, R;
	while(cin >> AN >> BN >> R, AN || BN || R)
	{

		vector<P> VecAN(AN);
		vector<int> VecBN[10001];
		for(int i = 0; i < AN; ++i)
		{
			cin >> VecAN[i].first >> VecAN[i].second;
		}
		int px, py;
		for(int i = 0; i < BN; ++i)
		{
			cin >> px >> py;
			VecBN[px].push_back(py);
		}
		for(int i = 0; i < 10001; ++i)
		{
			sort(VecBN[i].begin(), VecBN[i].end());
		}		
		int count = 0;
		for(int i = 0; i < AN; ++i)
		{
			int minx = max(0, VecAN[i].first - 4 * R);
			int maxx = min(10000, VecAN[i].first + 4 * R);
			for(int j = minx; j <= maxx; ++j)
			{
				if(VecBN[j].empty())
				{
					continue;
				}
				double temp = sqrt((double)(-(VecAN[i].first - j) * (VecAN[i].first - j) + 16 * R * R));
				int upperlimit = (int)(temp + VecAN[i].second + EPS);
				double lowerlimit2 = -temp + VecAN[i].second;
				int lowerlimit = (int)(lowerlimit2 + EPS);
				if(!EQ(lowerlimit2, (int)lowerlimit2))
				{
					lowerlimit++;
				}
				count += upper_bound(VecBN[j].begin(), VecBN[j].end(), upperlimit) - lower_bound(VecBN[j].begin(), VecBN[j].end(), lowerlimit);
			}
		}		
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;

int comb2(int n, int k){
  return n * (n-1) /2;
}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1){}
  int root(int x) {
    if(d[x]<0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y){
    x = root(x); y=root(y);
    if(x==y) return false;
    if (d[x]>d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x)==root(y);}
  int size(int x) {return -d[root(x)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      cout<<"d; " <<d[i] <<endl;
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  ll benrisa() {
    ll ans=0;
    rep(i,d.size()){
      if (d[i]<-1) {ans+=comb2(-d[i],2);}
    }
    return ans;
  }

  
};


int main(){
  string s;
  cin >>s;

  int q;
  cin>>q;

  int t,f;
  string c;

  string front, back;
  
  bool sei=true;
  
  rep(i, q){
    cin >> t;
    if(t==1) {
      if (sei==true) sei=false;
      else sei = true;
      continue;
    }
    cin >> f>>c;
    if(sei==true){
      // if(f==1) front.push_back(string(1),c);
      // else back.push_back(string(1),c);
      if(f==1) front+=c;
      else back+=c;
    }
    else{
      // if(f==1) back.push_back(string(1),c);
      // else front.push_back(string(1),c);
      if(f==1) back+=c;
      else front+=c;
    }
    
    
  }
  string ans;

  if(sei==1){
    reverse(ALL(front));
    ans = front + s + back;
  }

  else{
    reverse(ALL(back));
    reverse(ALL(s));
    ans = back + s + front;
    
  }
  cout << ans <<endl;
  
}




Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double m,sum=0,k;
	long long a,b,i;
	cin >> a;
	long double arr[a];
	for(i=0;i<a;i++)
	{
	cin >> arr[i];
	m=1/arr[i];
	sum+=m;
}
k=1/sum;
cout << k;
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
int i,j,a,b,min=1000,max=0;
  scanf ("%d",&j);
  for (i=0;i<j;i++){
  scanf ("%d",&a);
    if(max<a){
    max=a;
    }
    if(min>a){
    min=a;
    }
  }
  printf ("%d",max-min);
return 0;
}


Measured memory_bytes: 128
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  
  ll cnt = 0;
  rep(i,n-1)
  {
    if(i + 1 == a[i])
    {
      swap(a[i],a[i+1]);
      cnt++;
    }
  }

  if(a[n-1] == n)
  {
    swap(a[n-2],a[n-1]);
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {
  int h,w;
  while(true) {
    cin >> h >> w;
    if(h==0&&w==0) break;
    rep(i,h) {
      rep(j,w) {
        if((i+j)%2==0) {
          cout << "#";
        }else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll x,n;
    cin>>x>>n; 
    bool c[105];
    fill(c,false);
    ll a[n];
    for(ll i=0;i<n;i++){
      cin>>a[i];
      c[a[i]]=true; 
    }
    ll l=x,r=x;
    while(1){
      if(c[l]==false){
        cout<<l<<endl; 
        break; 
      }
      if(c[r]==false){
        cout<<r<<endl; 
        break; 
      }
      l--,r++;
    }
    
    //printclock;
    return 0;
}
    


Measured memory_bytes: 3560
n = int(input())
List = list(map(int,input().split()))
x = 0
min = List[0]
count = 0
#print(List.index(n))
#print(List[0:n])
#print(List[2])

for i in List:
    x = 0
    if i <= min:
        count += 1
        min = i

#print(x)
print(count)

Measured memory_bytes: 24744
/*
 * Rectangle.cpp
 *
 *  Created on: 2014/07/20
 *      Author: WanWan1985
 */
#include <iostream>
#include <string>
#include <stdlib.h> // for atof
using namespace std;

int main(void) {

	string strLine;
	// 入力
	getline(cin, strLine);

	unsigned int iPos = strLine.find(" ", 0);
	double dLengthWise = atof(strLine.substr(0, iPos).c_str());
	double dCrossWise = atof(strLine.substr(iPos + 1, strLine.size()).c_str());

	// 出力
	cout << dLengthWise * dCrossWise << " " << 2 * (dLengthWise + dCrossWise) << endl;

	return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
long long ABS(long long x){return x>=0?x:-x;}
int main(){
    int n;
    cin>>n;
    long long sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    long long ans=ABS(sum-2*a[0]),sum0=0;
    for(int i=0;i<n-1;i++){
        sum0+=a[i];
        if(ABS(sum-2*sum0)<ans){
            ans=ABS(sum-2*sum0);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

// 
// 

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int M = in.nextInt();
		int answer = 1;
		
		for (int i = (int) Math.sqrt(M); i > 0; i--) {
			if (M % i == 0) {
				int other = M / i;
				if (M / other >= N) {
					answer = Math.max(answer, other);
				}
				if (M / i >= N) {
					answer = Math.max(answer, i);
				}
			}
		}
		System.out.println(answer);
	}
}

class TreeNode {
	int val;
	TreeNode left;
	TreeNode right;

	TreeNode(int x) {
		val = x;
	}
}

class TreeDrawer {
	public static String treeNodeToString(TreeNode root) {
		if (root == null) {
			return "[]";
		}

		String output = "";
		Queue<TreeNode> nodeQueue = new LinkedList<>();
		nodeQueue.add(root);
		while (!nodeQueue.isEmpty()) {
			TreeNode node = nodeQueue.remove();

			if (node == null) {
				output += "null, ";
				continue;
			}

			output += String.valueOf(node.val) + ", ";
			nodeQueue.add(node.left);
			nodeQueue.add(node.right);
		}
		return "[" + output.substring(0, output.length() - 2) + "]";
	}

	public static TreeNode stringToTreeNode(String input) {
		input = input.trim();
		input = input.substring(1, input.length() - 1);
		if (input.length() == 0) {
			return null;
		}

		String[] parts = input.split(",");
		String item = parts[0];
		TreeNode root = new TreeNode(Integer.parseInt(item));
		Queue<TreeNode> nodeQueue = new LinkedList<>();
		nodeQueue.add(root);

		int index = 1;
		while (!nodeQueue.isEmpty()) {
			TreeNode node = nodeQueue.remove();

			if (index == parts.length) {
				break;
			}

			item = parts[index++];
			item = item.trim();
			if (!item.equals("null")) {
				int leftNumber = Integer.parseInt(item);
				node.left = new TreeNode(leftNumber);
				nodeQueue.add(node.left);
			}

			if (index == parts.length) {
				break;
			}

			item = parts[index++];
			item = item.trim();
			if (!item.equals("null")) {
				int rightNumber = Integer.parseInt(item);
				node.right = new TreeNode(rightNumber);
				nodeQueue.add(node.right);
			}
		}
		return root;
	}

	public static void prettyPrintTree(TreeNode node, String prefix, boolean isLeft) {
		if (node == null) {
			System.out.println("Empty tree");
			return;
		}

		if (node.right != null) {
			prettyPrintTree(node.right, prefix + (isLeft ? "│   " : "    "), false);
		}

		System.out.println(prefix + (isLeft ? "└── " : "┌── ") + node.val);

		if (node.left != null) {
			prettyPrintTree(node.left, prefix + (isLeft ? "    " : "│   "), true);
		}
	}

	public static void draw(TreeNode node) {
		prettyPrintTree(node, "", true);
	}
}


Measured memory_bytes: 23764
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;

void main() {
    int a, b, c;
    scan(a, b, c);
    writeln(a ^ b ^ c);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>

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

using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        map<string,pair<int,int> > ma;
        
        rep(i,n) {
            string s;
            int a,b;
            cin >> s >> a >> b;
            
            ma[s] = make_pair(b-a+1,b);
        }

        rep(i,m) {
            int x;
            cin >> x;
        
            bool flag = true;
            map<string,pair<int,int> >::iterator ite;
            for(ite = ma.begin();ite != ma.end();ite++) {
                int s = ite->second.first;
                int e = ite->second.second;

                if(s <= x && x <= e) {
                    cout << ite->first << " " << x - s + 1 << endl;
                    flag = false;
                    break;
                }
            }

            if(flag) cout << "Unknown" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k = 2;
    cin >> n;
    vector<int> arr(n);
    for (auto &x : arr) cin >> x;
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = i-1; j >= max(i-k, 0LL); --j)
            dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
    }
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<iostream>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,P1> P2;

int main(){
  bool t[20][20][4][101];
  int s[20][20],c[20][20][20][20];
  int i,k,m,n,ns,nc,nj,sw,sh,gw,gh;
  char a,b,z;

  while(cin>>m>>n/*scanf(" %d%d ",&m,&n)*/ && (m || n)){
    cin >> k >> ns;
    //scanf(" %d%d ",&k,&ns);
    fill(&c[0][0][0][0],&c[m-1][n-1][m-1][n-1]+1,k);

    fill(&s[0][0],&s[m-1][n-1]+1,0);
    for(i=0;i<ns;i++){
      cin>>a>>z>>sw>>k;
      //scanf(" %c%c%d%d ",&a,&z,&sw,&k);
      s[a-'a'][sw-1] = k;
    }

    scanf(" %d ",&nc);
    for(i=0;i<nc;i++){
      cin>>a>>z>>sw>>b>>z>>gw;
      //scanf(" %c%c%d %c%c%d ",&a,&z,&sw,&b,&z,&gw);
      c[a-'a'][sw-1][b-'a'][gw-1] = c[b-'a'][gw-1][a-'a'][sw-1] = -1;
    }

    scanf(" %d ",&nj);
    for(i=0;i<nj;i++){
      cin>>a>>z>>sw>>b>>z>>gw>>k;
      //scanf(" %c%c%d %c%c%d%d ",&a,&z,&sw,&b,&z,&gw,&k);
      c[a-'a'][sw-1][b-'a'][gw-1] += k;
      c[b-'a'][gw-1][a-'a'][sw-1] += k;
    }

    cin>>a>>z>>sw>>b>>z>>gw;
    //scanf(" %c%c%d %c%c%d ",&a,&z,&sw,&b,&z,&gw);
    sw--;gw--;
    sh = a-'a';gh = b-'a';

    fill(&t[0][0][0][0],&t[m-1][n-1][4][101]+1,false);
    t[sh][sw][0][0] = true;
    queue<P2> q;
    q.push(P2(P1(0,0),P1(sh,sw)));
    int ans = 1<<30;

    while(q.size()){
      P2 p=q.front();q.pop();
      int y = p.sc.fs,x = p.sc.sc;

      for(int dd=0;dd<4;dd++){
	if(dd==(p.fs.sc+2)%4)continue;
	int dy=y,dx=x,dt=p.fs.fs;
	if(dd==0)dx++;
	if(dd==1)dy++;
	if(dd==2)dx--;
	if(dd==3)dy--;
	if(dy<0 || dx<0 || m<=dy || n<=dx)continue;
	if(c[y][x][dy][dx]<0)continue;
	dt += c[y][x][dy][dx];
	if(dt>100)continue;
	k = s[dy][dx];
	if(k && ( ((dt/k)&1) == (dd&1) ) )continue;
	if(!t[dy][dx][dd][dt]){
	  if(dy==gh && dx==gw)ans = min(ans,dt);
	  t[dy][dx][dd][dt] = true;;
	  q.push(P2(P1(dt,dd),P1(dy,dx)));
	}
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))

def common_divisor(n):
    cd = []
    for i in range(1,int(n**0.5)+2):
        if n%i==0:
            cd.append(i)
            if i != n//i:
                cd.append(n//i)
    return set(cd)

#print(cd_dic)
cds = common_divisor(A[0]).union(common_divisor(A[1]))
ans = 1
for k in cds:
    #print(cd_dic)
    cnt = 0
    for a in A:
        if a%k!=0:
            cnt += 1
            if cnt == 2:
                break
    else:
        ans = max(ans,k)

print(ans)

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  vector<int> C(N, N);
  rep(j,K){
    vector<int> B(N+1,0);
    rep(i,N){
      int Le = max(0, i-A[i]);
      int Ri = min(N, i+A[i]+1);
      B[Le]++;
      B[Ri]--;
    }
    rep(i,N) B[i+1]+=B[i];
    B.pop_back();
    if(A==B) break;
    A=B;
  }
  rep(i,N){
    cout << A[i] << endl;
  }
}

Measured memory_bytes: 5572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_A(){
    
    REP(i,5){
        int x;
        cin >> x;
        if(x == 0) cout << i + 1 << endl;
    }
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2 * 1000 + 47;


int main()
{
    // freopen("in.txt", "r", stdin);
    string s;
    cin >> s;

    int ans = INF;
    FOR(ch, 'a', 'z'+1)
    {
        string S = s;
        int cnt = 0;
        while(true)
        {
            int ok = 1;
            FOR(i, 0, SZ(S))
            if (S[i] != ch)ok = 0;
            if (ok)break;
            ++cnt;
            string SS = "";
            FOR(i, 0, SZ(S) - 1)
            {
                if (S[i] == ch || S[i+1] == ch)
                    SS += ch;
                else SS += S[i];
            }
            S = SS;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    
    
    return 0;
}






Measured memory_bytes: 256
import math
import functools
N, A, B = map(int, input().split())
V = sorted([int(x) for x in input().split()], reverse=True)
print(sum(V[:A]) / A)
threshold = V[:A][-1]
fixed = 0
chosen = 0
for v in V:
  if v > threshold:
    fixed += 1
  elif v == threshold:
    chosen += 1
def nCn(a, b):
  return math.factorial(a) // math.factorial(b) // math.factorial(a - b)
if fixed:
  print(nCn(chosen, A - fixed))
else:
  count = 0
  for i in range(A, min(B, chosen) + 1):
    count += nCn(chosen, i)
  print(count)

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

int main() {
  int N, L;
  string s[110];
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
  	cin >> s[i];
  }
  
  sort(s, s + N);
  string sum;

  for (int i = 0; i < N; i++) {
    sum += s[i];
  }
  cout << sum << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ans = max(a - b * 2, 0);

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


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int A[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	multiset<int> ss;
	ss.insert(A[0]);
	FOR(i, 1, N) {
		auto it = ss.lower_bound(A[i]);
		if (it != ss.begin()) {
			--it;
			ss.erase(it);
		}
		ss.insert(A[i]);
	}
	
	cout << ss.size() << endl;
	
	return 0;
}


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

using namespace std;

#define ll long long
#define pii pair<int,int>
#define mod 1000000007
int main()
{
	int n;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	long long sum = a[n-1];
	long long ans = 0;
	// cout<<"debug"<<endl;
	for(int i=n-2;i>=0;i--)
	{

		ans = (ans + (a[i]*sum)%mod)%mod;
		sum = (sum + a[i])%mod; 
	}
	cout<<ans<<endl;
}

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

int main() {
  long long H,ans=0;
  cin >> H;
  
  for(int i=0;;i++){
    H /= 2;
    ans += pow(2,i);
    if(H<=0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#define maxn 505
#define maxm 100005
using namespace std;
int n,m,ans,x[maxm],y[maxm];
bool ok[maxn],vis[maxn][maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
bool DFS(int stp,int id){
	if (!stp) return 1;
	if (vis[id][x[stp]]&&vis[id][y[stp]]) return 0;
	if (vis[id][x[stp]]) vis[id][y[stp]]=1;
	if (vis[id][y[stp]]) vis[id][x[stp]]=1;
	return DFS(stp-1,id);
}
int main(){
	n=read();m=read();
	for (int i=1;i<=m;i++) x[i]=read(),y[i]=read();
	for (int i=1;i<=n;i++) vis[i][i]=1,ok[i]=DFS(m,i);
	for (int i=1;i<n;i++) if (ok[i])
	for (int j=i+1;j<=n;j++) if (ok[j]){
		bool flg=1;
		for (int k=1;k<=n;k++)
		if (vis[i][k]&&vis[j][k]){flg=0;break;}
		ans+=flg;
	}
	printf("%d\n",ans);
	return 0;
}

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

ll calc(ll a, ll b)
{
	if (a==b) return a;
	if (a>b) swap(a,b);
	if (b%a==0)
	{
		return a*(2*(b/a)-1);
	}
	else
	{
		return a*(2*(b/a))+calc(a,b%a);
	}
}

int main()
{
	ll n,x;
	cin >> n >> x;
	cout << n+calc(n-x,x) << endl;
	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, m, a, b, vis[MX], c = 0, d[MX];
vi adj[MX];

void yes () { cout << "Yes" << endl; exit(0); }
void no () { cout << "No" << endl; exit(0); }

void dfs (int u) {
	if (u == b) c++;
	if (vis[u]) return;
	vis[u] = 1;
	for (int v : adj[u])
		dfs(v);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
		d[a]++, d[b]++;
	}

	for (int i = 1; i <= n; i++) {
		if (d[i] & 1)
			no();
		c += d[i] == 4;
	}

	for (int i = 1; i <= n; i++)
		if (d[i] >= 6)
			yes();

	if (c >= 3) yes();

	if (c == 2) {
		a = b = -1;
		for (int i = 1; i <= n; i++)
			if (d[i] == 4) {
				if (a == -1) a = i;
				else b = i;
			}
		c = 0;
		vis[b] = 1;
		dfs(a);
		if (c == 2) yes();
	} 

	no();
	
	return 0;
}

Measured memory_bytes: 7296
a = int(input())
b = list(map(int,input().split()))
c = 0
for i in range(len(b)):
    if b[i]%2 ==0:
        if b[i]%3 != 0 and b[i]%5!=0:
            c = 1
        
if c==1:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
#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(void){
    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: 384
#include <bits/stdc++.h>

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    REP(i,s.size()){
        int index = ((s[i] - 'A') + n)%26;
        s[i] = index + 'A';
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int R;
  scanf("%d", &R);
  if(R < 1200) {
    printf("ABC\n");
  } else if(R < 2800) {
    printf("ARC\n");
  } else {
    printf("AGC\n");
  }
  return 0;
}


Measured memory_bytes: 128
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202006_5th/D_input.txt")
else:
    f=sys.stdin
ans_sum=0
n=int(f.readline().strip())
for _ in range(1,n+1):
    num=n//_
    ans_sum+=_*((num*(num+1))//2)
print(ans_sum)

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

int main()
{
    int n ;
    cin>> n ;
    map<string,int>mp ;
    while (n--)
    {
        string str ;
        cin>> str ;
        mp[str]++ ;

    }
    cout<< "AC"<<" " <<"x"<<" "<<mp["AC"]<<endl ;
    cout<< "WA"<<" " <<"x"<<" "<<mp["WA"]<<endl ;
    cout<< "TLE"<<" " <<"x"<<" "<<mp["TLE"]<<endl ;
    cout<< "RE"<<" " <<"x"<<" "<<mp["RE"]<<endl ;
}


Measured memory_bytes: 3584
#17:23
x,y = map(int,input().split())
if (x+y) % 3 != 0:
  print(0)
elif x*2 < y or y*2 < x:
  print(0)
else:
  a = (x + y) // 3
  b = y - a
  mod = 10 ** 9 + 7
  def inv(x):
    y = 1
    while x != 1:
      y *= mod // x + 1
      y %= mod
      x -= mod % x
    return y
  ans = 1
  for i in range(b):
    ans *= a - i
    ans %= mod
    ans *= inv(b-i)
    ans %= mod
  print(ans)

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

using namespace std;

typedef long long ll;

map<string,ll> mp;
signed main()
{	
	ll n;
	cin>>n;
	string s;
	vector<string> v;
	set<string> st;

	while(n--)
	{
		cin>>s;
		sort(s.begin(),s.end());
		st.insert(s);
		mp[s]++;
	}
	
	ll cnt=0;
	for(string temp: st)
	{
		cnt+=((mp[temp])*(mp[temp]-1))/2;
	}

	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n,a[100010],b[100010],c[100010];

void solve()
{
    cin>>n;REP(i,n)cin>>a[i];REP(i,n)cin>>b[i];REP(i,n)cin>>c[i];
    sort(a,a+n);sort(b,b+n);sort(c,c+n);
    ll ans=0;
    REP(i,n)ans+=(lower_bound(a,a+n,b[i])-a)*(c+n-upper_bound(c,c+n,b[i]));
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    string C1,C2;
    cin >> C1 >> C2;
    if(C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0]) cout << "YES" << endl;
    else cout << "NO" << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
 #include <numeric>
using namespace std;
 
vector<bool> c;
vector<int> b;
bool done;
 
void dp(int depth);
 
int main(){
    done = false;
    vector<char> a;
    a.resize(4);
    b.resize(4);
    c.resize(3);
    copy_n(istream_iterator<char>(cin), 4, a.begin());
    transform(a.begin(), a.end(), b.begin(), [](char i){ return (int)(i - '0'); });
    dp(0);
    return 0;
}
 
void dp(int depth){
    if(done) return;
    if(depth >= 3){
        vector<int>::iterator bi = b.begin();
        int sum = accumulate(c.begin(), c.end(), b[0], [&bi](int i, bool j){bi++; return (j ? i + *bi : i - *bi); });
        if(sum != 7) return;
        cout << b[0];
        bi = b.begin();
        for_each(c.begin(), c.end(), [&bi](bool j){bi++; cout << (j ? "+" : "-") << *bi; });
        cout << "=7" << endl;
        done = true;
    }else{
        c[depth] = true;
        dp(depth + 1);
        c[depth] = false;
        dp(depth + 1);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;

typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
const int inf = 1e9;
const ll INF = 2e18;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int main(){
	string sai[]={
		"3542",
		"3146",
		"6512",
		"2156",
		"6413",
		"2453"
	};
	int A[]={-1,3,4,1,2,-1};
	int B[]={-1,0,1,5,1,-1};
	int n;
	while(cin>>n,n){
		vvi fil(300,vi(300));
		vvi num(300,vi(300));
		while(n--){
			int x=150,y=150;
			int a,b;
			cin>>a>>b;
			while(1){
				string tmp=sai[a-1];
				while(tmp[0]-'0'!=b)tmp=tmp[3]+tmp.substr(0,3);
				string s=to_string(a)+tmp+to_string(7-a);
//				cout<<s<<endl;
				int ma=-1;
				loop(i,1,5)if(s[i]>='4'){
					int nx=x+dx[i-1];
					int ny=y+dy[i-1];
//					cout<<s<<endl;
//					cout<<x<<" "<<y<<" "<<nx<<" "<<ny<<endl;
//					cout<<fil[x][y]<<" "<<fil[nx][ny]<<endl;
					if(fil[x][y]>fil[nx][ny]){
						ma=max(ma,(int)s[i]);
					}
				}
//				cout<<endl;
//				loop(X,145,155){loop(Y,145,155)cout<<" "<<fil[X][Y];cout<<endl;}
//				cout<<endl;
//				loop(X,145,155){loop(Y,145,155)cout<<" "<<num[X][Y];cout<<endl;}
//				cout<<s<<endl;
				if(ma==-1){
					fil[x][y]++;
					num[x][y]=s[0]-'1';
					break;
				}
				rep(i,6)if(ma==s[i]){
					a=s[A[i]]-'0';
					b=s[B[i]]-'0';
	//				cout<<a<<" "<<b<<endl;
					x+=dx[i-1];
					y+=dy[i-1];
				}
			}
		}
		vi co(6);
		rep(i,300)rep(j,300)if(fil[i][j])co[num[i][j]]++;
		rep(i,5)cout<<co[i]<<" ";
		cout<<co[5]<<endl;
	}
}

Measured memory_bytes: 3696
from collections import deque
from copy import deepcopy
n = int(input())
a = list(map(int,input().split()))
q = int(input())

for i in range(q):
    b,m,e = map(int,input().split())
    tmp = deepcopy(a)
    for k in range(e-b):
        a[b+(k+e-m)%(e-b)] = tmp[b+k]

print(*a)


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

int main() {
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		char[] in=s.next().toCharArray();
		int k=s.nextInt();
		for(int i=0;i<in.length;i++) {
			if(in[i]!='a'&&'z'-in[i]<k) {
				k-='z'-in[i]+1;
				in[i]='a';
			}
		}
		k%=26;
		in[in.length-1]=(char) (((in[in.length-1]-'a'+k)%26)+'a');
		System.out.println(String.valueOf(in));
	}
}


Measured memory_bytes: 26208
#include<iostream>
#include<vector>
using namespace std;
static const int N = 100;

bool isSequence(vector<int> v){
  int d = v[1] - v[0];
  for ( int i = 1; i < v.size(); i++ ){
    if ( v[i] -  v[i-1] != d ) return false;
  }
  return true;
}

bool isSeq(vector<int> A,int n){
  int d = A[1] - A[0];
  for ( int i = 1; i < n; i++ ){
    if ( A[i] - A[i-1] != d ) return false;
  }
  return true;
}

main(){
  vector<int> A;
  int n, x;
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    A.resize(n+1);
    for ( int i = 0; i < n+1; i++ ) {
      cin >> A[i];
    }

    for ( int i = 0; i < n+1; i++ ){
      vector<int> tmp = A;
      tmp.erase(tmp.begin() + i);
      if ( isSequence(tmp) ) {
	cout << A[i] << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1224
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int num[INPUT_NUMBER];
    int numrec;
    int i;
    
    for(i=0;i<=INPUT_NUMBER-1;i++){
        scanf("%d",&num[i]);
    }

    //printf("recording done\n");

    for(i=0;i<=INPUT_NUMBER-1;i++){
        for(int h=0;h<=INPUT_NUMBER-i-2;h++){
            if(num[h]>num[h+1]){
                numrec=num[h+1];
                num[h+1]=num[h];
                num[h]=numrec;
            }
        }
    }

    for(i=0;i<=INPUT_NUMBER-2;i++){
        printf("%d ",num[i]);
    }

    printf("%d\n",num[INPUT_NUMBER-1]);

    return 0;
}


Measured memory_bytes: 1940
#include<bits/stdc++.h>  
using namespace std; 
using ll  = long long;
const ll INF = 1e18 + 5;
int main() { 
	int n;
	cin >> n;
	vector<ll> arr(n,0);
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
	}
	vector<vector<pair<ll,ll>>> dp(n, vector<pair<ll,ll>> (n,{INF,(ll)-1}));
	
	for(int i = n-1; i >= 0; i--){
		for(int j = i; j < n; ++j){
			if(i == j){
				dp[i][j] = {0,arr[i]};
				continue;
			}
			for(int k = i; k < j; ++k){
				ll temp = dp[i][k].first + dp[i][k].second + dp[k+1][j].first + dp[k+1][j].second;
				if(dp[i][j].first > temp){
					dp[i][j] =  {temp,dp[i][k].second + dp[k+1][j].second};
				}
			}
		}
	}
	cout << dp[0][n-1].first<<endl;
	
} 


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fill(a, i) memset(a, i, sizeof(a))
#define all(vec) vec.begin(),vec.end()
#define revall(vec) vec.rbegin(),vec.rend()
#define vl vector<ll>
#define tlll tuple<ll, ll, ll>
#define pb push_back
#define fr(i, a, b) for (int i = a; i < b; ++i)  
ll mod=1e9+7;
const ll maxn=1e5+5;
vl adj[maxn]; 
ll dp[maxn][2];
ll n;
bool visited[maxn];
ll dfs(ll u,ll p,ll idx)
{
    // cout<<p<<endl;
    if(visited[u])
    {
        // cout<<u<<endl;
        ll ans = idx==1?dp[u][0]:dp[u][1]+dp[u][0];
        // cout<<ans<<" "<<u <<endl;
        return ans%mod;
    }
    visited[u]=1;
    fr(k,0,2)
    {
        ll temp=1;
        fr(i,0,adj[u].size())
        {
            if(adj[u][i]!=p)
            {
            // if(u==2)
            // cout<<"OK "<<adj[u][i]<<" "<<p<<" "<<u <<endl;

            temp=(temp*dfs(adj[u][i],u,k))%mod;
            }
        }
        // cout<<temp<<endl;
        dp[u][k]=temp;
    }
    ll ans = idx==1?dp[u][0]:dp[u][1]+dp[u][0] ;
    // cout<<ans<<" "<<u <<endl;
    return ans%mod;
}
void solve()
{
    cin>>n;
    fr(i,0,n-1)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    // for(int i=1;i<=n;++i)
    // {
    //     for(int j=0;j<adj[i].size();++j)
    //     cout<<adj[i][j]<<" ";
    //     cout<<endl;
    // }
    // cout<<"done\n";
    ll ans=0;
    fr(k,0,2)
    {
        ll temp=1;
        temp=dfs(1,0,k);
        // dp[1][k]=temp;
        // ans=(ans+temp)%mod;
    }
    // fr(i,1,n+1)
    // cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    // // cout<<ans;
    cout<<(dp[1][0]+dp[1][1])%mod;
}
int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
    solve();
}

Measured memory_bytes: 17504
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cctype>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int n;
  string s;
  string s1;
  string s2;
  cin >> n >> s;
  s1 = s.substr(0,n/2);
  s2 = s.substr(n/2);
  if(s1 == s2){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  if(N%1000 == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - (N%1000) << endl;
  return 0;
}


Measured memory_bytes: 3632
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main()
{
    int N;
    cin >> N;
    vector<int> A(N,0);
    vector<int> B(N,0);
    vector<int> C(N-1,0);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];

    int sat = 0;
    rep(i,N){
        sat += B[A[i]-1];
        if(A[i] == A[i+1] - 1)  sat += C[A[i]-1];//Cの満足度加算
    }
    cout << sat;
    return 0;
}

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

int main(){
  long long n;
  long long L[87] = {2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, 370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, 17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, 505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, 9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, 162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, 1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, 20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, 221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843};
  cin >> n;
  cout << L[n] << endl;
  return(0);
}


Measured memory_bytes: 256